question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stream stack does not take care of garbage-collected Stream (i.e. weakref is None)

See original GitHub issue
import cupy as cp
from cupy import cuda

with cuda.Stream() as s1:
    s2 = cuda.Stream()
    s2.use()
    with cuda.Stream() as s3:
        del s2

This fails when exiting s3 context:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    del s2
  File "cupy/cuda/stream.pyx", line 197, in cupy.cuda.stream.BaseStream.__exit__
  File "cupy/cuda/stream.pyx", line 34, in cupy.cuda.stream._ThreadLocal.set_current_stream_ref
AttributeError: 'NoneType' object has no attribute 'ptr'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
kmaehashicommented, May 15, 2021

I think this line is problematic:

Yes, we need to rewind the stream stack until we find an alive one. If everything is dead we should fallback to the default stream.

1reaction
emcastillocommented, Apr 27, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why objects not being garbage collected while executing Java ...
I'm trying to understand what holds the reference to the objects so that they are not eligible for garbage collection when Java Stream...
Read more >
garbage collection - What use is a non-zeroing weak reference?
If we remove that reference, the refcount hits zero (or not, if other references were made), and the memory can be reclaimed. The...
Read more >
weakref — Weak references — Python 3.11.1 documentation
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are...
Read more >
proposal-weakrefs/weakrefs.md at master - GitHub
A weak reference is a reference that allows access to an object that has not yet been garbage collected, but does not prevent...
Read more >
Weak References | Microsoft Learn
A weak reference permits the garbage collector to collect the object while still allowing the application to access the object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found