Stream stack does not take care of garbage-collected Stream (i.e. weakref is None)
See original GitHub issueimport 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:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Related https://github.com/cupy/cupy/pull/4337