scipy: Seg fault when importing torch
In the latest release, if you import scipy and then pytorch, it’ll segfault. This did not happen in 1.3.3. It started at 1.4.0rc2
Reproducing code example:
# From a new virtualenv...
(venv) $ pip3 install torch
Collecting torch
Using cached https://files.pythonhosted.org/packages/f9/34/2107f342d4493b7107a600ee16005b2870b5a0a5a165bdf5c5e7168a16a6/torch-1.3.1-cp37-cp37m-manylinux1_x86_64.whl
Collecting numpy (from torch)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/9b/af/4fc72f9d38e43b092e91e5b8cb9956d25b2e3ff8c75aed95df5569e4734e/numpy-1.17.4-cp37-cp37m-manylinux1_x86_64.whl
Installing collected packages: numpy, torch
Successfully installed numpy-1.17.4 torch-1.3.1
(venv) $ python3 -c "import scipy;import torch"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
(venv) $ pip3 install scipy
Collecting scipy
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/37/9d/a606dc7b17ef0b7326afd128e132b7a483d5611da603334842df75d92d3c/scipy-1.4.0-cp37-cp37m-manylinux1_x86_64.whl (26.1MB)
100% |████████████████████████████████| 26.1MB 47kB/s
Requirement already satisfied: numpy>=1.13.3 in ./venv/lib/python3.7/site-packages (from scipy) (1.17.4)
Installing collected packages: scipy
Successfully installed scipy-1.4.0
(venv) $ python3 -c "import scipy;import torch"
Segmentation fault (core dumped)
Error message:
Since it’s a segfault, I posted the GDB stacktrace here: https://gist.github.com/jdavidberger/b1d9870f4501a16fc4346bda46f98413
Scipy/Numpy/Python version information:
1.4.0 1.17.4 sys.version_info(major=3, minor=7, micro=5, releaselevel='final', serial=0)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 21 (14 by maintainers)
Links to this issue
Commits related to this issue
- BLD: update to pybind11 2.4.0, fixes a critical segfault in SciPy 1.4.0 See https://github.com/scipy/scipy/issues/11237 and https://github.com/pybind/pybind11/issues/1262 for details. tl;dr pybind11... — committed to rgommers/scipy-wheels by rgommers 5 years ago
- BLD: update to pybind11 2.4.3, fixes a segfault with SciPy 1.4.0 See https://github.com/scipy/scipy/issues/11237 and https://github.com/pybind/pybind11/issues/1262 for details. tl;dr pybind11 is the... — committed to rgommers/scipy-wheels by rgommers 5 years ago
- BLD: update minimum pybind11 version to 2.4.0. Related to gh-11237 — committed to rgommers/scipy by rgommers 5 years ago
- BLD: update to pybind11 2.4.3, fixes a segfault with SciPy 1.4.0 See https://github.com/scipy/scipy/issues/11237 and https://github.com/pybind/pybind11/issues/1262 for details. tl;dr pybind11 is the... — committed to tylerjereddy/scipy-wheels by rgommers 5 years ago
- BLD: update to pybind11 2.4.3, fixes a segfault with SciPy 1.4.0 (#61) See https://github.com/scipy/scipy/issues/11237 and https://github.com/pybind/pybind11/issues/1262 for details. tl;dr pybind... — committed to MacPython/scipy-wheels by tylerjereddy 5 years ago
- BLD: update minimum pybind11 version to 2.4.0. Related to gh-11237 — committed to tylerjereddy/scipy by rgommers 5 years ago
- fixed scipy version See https://github.com/scipy/scipy/issues/11237 — committed to kan-bayashi/espnet by kan-bayashi 5 years ago
- Update setup.cfg to avoid Linux segfault issue See https://github.com/scipy/scipy/issues/11237 — committed to py-why/EconML by kbattocchi 5 years ago
- Pin scipy to 1.4.1. Fixes segfaults caused by scipy/scipy#11237 before 1.4.1 (observed at scipy==1.4.0 and any version of TF and scipy==1.1.0 and TF==2.1.0rc1 on a specific VM setup) PiperOrigin-Rev... — committed to tensorflow/tensorflow by mihaimaruseac 5 years ago
- Pin scipy to 1.4.1. Fixes segfaults caused by scipy/scipy#11237 before 1.4.1 (observed at scipy==1.4.0 and any version of TF and scipy==1.1.0 and TF==2.1.0rc1 on a specific VM setup) PiperOrigin-Rev... — committed to tensorflow/tensorflow by mihaimaruseac 5 years ago
- For python2, pin scipy to 1.2.2 (latest released). This means py2 won't get the fix in scipy/scipy#11237 PiperOrigin-RevId: 286456504 Change-Id: Ic94ee7e57dd6ea590d79aa643e5de4192709ff17 — committed to tensorflow/tensorflow by mihaimaruseac 5 years ago
- For python2, pin scipy to 1.2.2 (latest released). This means py2 won't get the fix in scipy/scipy#11237 PiperOrigin-RevId: 286456504 Change-Id: Ic94ee7e57dd6ea590d79aa643e5de4192709ff17 — committed to tensorflow/tensorflow by mihaimaruseac 5 years ago
- Remove pinning of scipy in `pip_new.sh`. That script still needs to run under py2 and py3 and latest scipy for py2 is 1.2.2. Hence, we cannot pin to 1.4.1 to get the fix for scipy/scipy#11237 under p... — committed to tensorflow/tensorflow by mihaimaruseac 5 years ago
We are seeing a segfault with
scipy 1.14
in a clean conda environment importing our own library (https://github.com/SeldonIO/alibi/blob/master/setup.py), everything works fine with1.13
.scipy
is an indirect dependency so not sure what is going wrong, we don’t usetorch
but we do usetensorflow
.Oops, yes, I failed to mention: Importing torch on it’s own is fine; as is importing torch before scipy.
I can also post an issue on pytorch’s issue tracker, but the thing that changed in my dev environment was going from scipy 1.3.3 to 1.4.0. I don’t know where the bug is exactly; but I figured since 1.4 is just out it’d be good to post here.
The patched wheels are up on PyPI now, so this may help if you use pip:
pip install scipy==1.4.1
Let’s see if our wheel builds are happy with the latest Pybind11: https://github.com/MacPython/scipy-wheels/pull/60
Confirmed that
pip install tf-nightly scipy==1.4.1
fixes the TF issues. Thank youI’m having the same issue:
root@261246f307ae:~/src# python --version Python 3.6.8
on Ubuntu16.04 running on Docker. I’m investigating why on two different machines I get the error just one one of them…
Nice find @peterbell10, we should release a 1.4.1 built with pybind11 2.4.0 asap I think, a lot of people are going to hit this problem quickly:(