I’m getting a segmentation fault (core dump) when using functions on large arrays in torch after the recent update. So for instance
torch.tanh(torch.randn((1000,5)))
and
torch.randn((1000,5)).exp()
both dump with PyTorch 2.3 but run successfully with PyTorch 2.1
This behavior is limited to performing functional operations on the large arrays. I can do
torch.randn((1000,5)) @ torch.randn((5,1000))
successfully in both versions of PyTorch (and with larger arrays).
This is all occurring in a fresh venv. Please let me know what other information would be helpful (other library version information, etc)
A stacktrace would be needed as I cannot reproduce these issues.
in ipython I only get Segmentation fault: 11
and in a Jupyter notebook the kernel dies. There’s no trackback for the error. But I did just try in a regular python environment and the functions seem to work – so can this be an ipython issue? Odd that it fixes itself when I change PyTorch versions.
Yes, it seems to have at least a dependency on IPython. You could run it via:
gdb --args ipython ...
...
run
...
bt
to get the backtrace after it segfaults.
I don’t have gdb
(M1 Mac Silicon), and I was getting weird errors with lldb
(with any process launch
command I got error: invalid target, create a target using the 'target create' command
, which then failed with some weird host
requirement that I couldn’t get around), but using the built-in faulthandler
via faulthandler.enable()
seemed to work. When I try torch.randn((5000,)).exp()
I am getting for example
Fatal Python error: Segmentation fault
Thread 0x00000001709df000 (most recent call first):
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/IPython/core/history.py", line 836 in _writeout_input_cache
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/IPython/core/history.py", line 853 in writeout_cache
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/IPython/core/history.py", line 61 in only_when_enabled
File Segmentation fault: 11
For torch.tanh(torch.randn((5000,)))
the same lines print as do
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/decorator.py", line 232 in fun
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/IPython/core/history.py", line 908 in run
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/IPython/core/history.py", line 61 in only_when_enabled
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/site-packages/decorator.py", line 232 in fun
File "/Users/sammcd/micromamba/envs/s4/lib/python3.12/threading.py", line 1073 in _bootstrap_inner