-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
🐛 Bug
I'd like to print the return of the gc.get_objects() function (I have memory issues) but I can't. Whenever I do it, I get the following error :
Traceback (most recent call last):
File "test.py", line 5, in <module>
print(gc.get_objects())
File "<frozen importlib._bootstrap>", line 302, in _module_repr
File "<frozen importlib._bootstrap>", line 295, in _module_repr
File ".../site-packages/torch/_ops.py", line 60, in __getattr__
op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator __file__::__file__But what's more strange is that using the length are affecting it to a variable (not printing it) doesn't produce an error.
To Reproduce
I'm using python3.7.0 and latest version of pytorch (1.0.1.post2). Just run the following code in a file :
import gc
import torch
print(len(gc.get_objects)) # Works
a = gc.get_objects() # works
print(gc.get_objects()) # Fails
for obj in gc.get_objects():
print(obj) # Works until encountering torch
# Though it works on some files
print(sum(map(sys.getsizeof, gc.get_objects()))) # Works
print(collections.Counter(map(type, gc.get_objects()))) # WorksPossible understanding
I think there's a use of the __file__ variable somewhere and according to this answer of SO, if the application is frozen it just fails using the variable.
Hope you can help
Edit : added more working examples
Edit 2 : I conducted some experiments, and it seems it's only due to the printing part. I navigated in the files but don't understand where to look when I encounter torch._C