Alex Davies
Alex Davies

Reputation: 41

Segmentation fault when importing torch-sparse (installing pytorch-geometric)

I am trying to install pytorch-geometric for a deep-learning project. Torch-sparse is throwing segmentation faults when I attempt to import it (see below). Initially I tried different versions of each required library, as I thought it might be a GPU issue, but I've since tried to simplify by installing cpu-only versions.

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torch_scatter
>>> import torch_cluster
>>> import torch_sparse
Segmentation fault (core dumped)

And the same issue, presumably due to torch_sparse, when importing pytorch_geometric:

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch_geometric
Segmentation fault (core dumped)

I'm on an Ubuntu distribution:

Distributor ID:    Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy

Here's my (lightweight for DL) conda installs:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
blas                      1.0                         mkl  
brotlipy                  0.7.0           py310h7f8727e_1002  
bzip2                     1.0.8                h7b6447c_0  
ca-certificates           2022.07.19           h06a4308_0  
certifi                   2022.9.24       py310h06a4308_0  
cffi                      1.15.1          py310h74dc2b5_0  
charset-normalizer        2.0.4              pyhd3eb1b0_0  
cpuonly                   2.0                           0    pytorch
cryptography              37.0.1          py310h9ce1e76_0  
fftw                      3.3.9                h27cfd23_1  
idna                      3.4             py310h06a4308_0  
intel-openmp              2021.4.0          h06a4308_3561  
jinja2                    3.0.3              pyhd3eb1b0_0  
joblib                    1.1.1           py310h06a4308_0  
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0               h1234567_1  
libgfortran-ng            11.2.0               h00389a5_1  
libgfortran5              11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
libuuid                   1.0.3                h7f8727e_2  
markupsafe                2.1.1           py310h7f8727e_0  
mkl                       2021.4.0           h06a4308_640  
mkl-service               2.4.0           py310h7f8727e_0  
mkl_fft                   1.3.1           py310hd6ae3a3_0  
mkl_random                1.2.2           py310h00e6091_0  
ncurses                   6.3                  h5eee18b_3  
numpy                     1.23.3          py310hd5efca6_0  
numpy-base                1.23.3          py310h8e6c178_0  
openssl                   1.1.1q               h7f8727e_0  
pip                       22.2.2          py310h06a4308_0  
pycparser                 2.21               pyhd3eb1b0_0  
pyg                       2.1.0           py310_torch_1.12.0_cpu    pyg
pyopenssl                 22.0.0             pyhd3eb1b0_0  
pyparsing                 3.0.9           py310h06a4308_0  
pysocks                   1.7.1           py310h06a4308_0  
python                    3.10.6               haa1d7c7_0  
pytorch                   1.12.1             py3.10_cpu_0    pytorch
pytorch-cluster           1.6.0           py310_torch_1.12.0_cpu    pyg
pytorch-mutex             1.0                         cpu    pytorch
pytorch-scatter           2.0.9           py310_torch_1.12.0_cpu    pyg
pytorch-sparse            0.6.15          py310_torch_1.12.0_cpu    pyg
readline                  8.1.2                h7f8727e_1  
requests                  2.28.1          py310h06a4308_0  
scikit-learn              1.1.2           py310h6a678d5_0  
scipy                     1.9.1           py310hd5efca6_0  
setuptools                63.4.1          py310h06a4308_0  
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.39.3               h5082296_0  
threadpoolctl             2.2.0              pyh0d69192_0  
tk                        8.6.12               h1ccaba5_0  
tqdm                      4.64.1          py310h06a4308_0  
typing_extensions         4.3.0           py310h06a4308_0  
tzdata                    2022e                h04d1e81_0  
urllib3                   1.26.12         py310h06a4308_0  
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.2.6                h5eee18b_0  
zlib                      1.2.13               h5eee18b_0  

Any help would be greatly appreciated!

Upvotes: 4

Views: 2598

Answers (1)

Alex Davies
Alex Davies

Reputation: 41

I've found a combination of packages that works for me - hopefully someone else will have this issue at some point and be able to reproduce the steps from me talking to myself here. The full process for getting stuff working was:

  1. Fresh conda environment with forced Python=3.9 (conda create -n ENVNAME python=3.9)
  2. Activate that environment
  3. Install basic python packages (conda install numpy pandas matplotlib scikit-learn)
  4. Check CUDA version if working with a GPU (nvidia-smi in terminal prints these details for NVIDIA cards)
  5. Install Pytorch using their suggested conda command (conda install pytorch torchvision torchaudio cudatoolkit=CUDA_VERSION -c pytorch -c conda-forge). This had to go through the env solving process on my machine.
  6. Install pytorch geometric (or just torch sparse if that's all you need) with conda install pyg -c pyg. Again this had a solving process.
  7. Check that torch_sparse imports without fault

Here's the conda list for this working combination of packages:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
blas                      1.0                         mkl  
bottleneck                1.3.5            py39h7deecbd_0  
brotli                    1.0.9                h5eee18b_7  
brotli-bin                1.0.9                h5eee18b_7  
brotlipy                  0.7.0           py39hb9d737c_1004    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.9.24            ha878542_0    conda-forge
certifi                   2022.9.24        py39h06a4308_0  
cffi                      1.14.6           py39he32792d_0    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
cryptography              37.0.2           py39hd97740a_0    conda-forge
cudatoolkit               11.6.0              hecad31d_10    conda-forge
cycler                    0.11.0             pyhd3eb1b0_0  
dbus                      1.13.18              hb2f20db_0  
expat                     2.4.9                h6a678d5_0  
ffmpeg                    4.3                  hf484d3e_0    pytorch
fftw                      3.3.9                h27cfd23_1  
fontconfig                2.13.1               h6c09931_0  
fonttools                 4.25.0             pyhd3eb1b0_0  
freetype                  2.11.0               h70c0345_0  
giflib                    5.2.1                h7b6447c_0  
glib                      2.69.1               h4ff587b_1  
gmp                       6.2.1                h58526e2_0    conda-forge
gnutls                    3.6.13               h85f3911_1    conda-forge
gst-plugins-base          1.14.0               h8213a91_2  
gstreamer                 1.14.0               h28cd5cc_2  
icu                       58.2                 he6710b0_3  
idna                      3.4                pyhd8ed1ab_0    conda-forge
intel-openmp              2021.4.0          h06a4308_3561  
jinja2                    3.0.3              pyhd3eb1b0_0  
joblib                    1.1.1            py39h06a4308_0  
jpeg                      9e                   h7f8727e_0  
kiwisolver                1.4.2            py39h295c915_0  
krb5                      1.19.2               hac12032_0  
lame                      3.100             h7f98852_1001    conda-forge
lcms2                     2.12                 h3be6417_0  
ld_impl_linux-64          2.38                 h1181459_1  
lerc                      3.0                  h295c915_0  
libbrotlicommon           1.0.9                h5eee18b_7  
libbrotlidec              1.0.9                h5eee18b_7  
libbrotlienc              1.0.9                h5eee18b_7  
libclang                  10.0.1          default_hb85057a_2  
libdeflate                1.8                  h7f8727e_5  
libedit                   3.1.20210910         h7f8727e_0  
libevent                  2.1.12               h8f2d780_0  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0               h1234567_1  
libgfortran-ng            11.2.0               h00389a5_1  
libgfortran5              11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libiconv                  1.17                 h166bdaf_0    conda-forge
libllvm10                 10.0.1               hbcb73fb_5  
libpng                    1.6.37               hbc83047_0  
libpq                     12.9                 h16c4e8d_3  
libstdcxx-ng              11.2.0               h1234567_1  
libtiff                   4.4.0                hecacb30_0  
libuuid                   1.0.3                h7f8727e_2  
libwebp                   1.2.4                h11a3e52_0  
libwebp-base              1.2.4                h5eee18b_0  
libxcb                    1.15                 h7f8727e_0  
libxkbcommon              1.0.1                hfa300c1_0  
libxml2                   2.9.14               h74e7548_0  
libxslt                   1.1.35               h4e12654_0  
lz4-c                     1.9.3                h295c915_1  
markupsafe                2.1.1            py39h7f8727e_0  
matplotlib                3.5.2            py39h06a4308_0  
matplotlib-base           3.5.2            py39hf590b9c_0  
mkl                       2021.4.0           h06a4308_640  
mkl-service               2.4.0            py39h7f8727e_0  
mkl_fft                   1.3.1            py39hd3c417c_0  
mkl_random                1.2.2            py39h51133e4_0  
munkres                   1.1.4                      py_0  
ncurses                   6.3                  h5eee18b_3  
nettle                    3.6                  he412f7d_0    conda-forge
nspr                      4.33                 h295c915_0  
nss                       3.74                 h0370c37_0  
numexpr                   2.8.3            py39h807cd23_0  
numpy                     1.23.3           py39h14f4228_0  
numpy-base                1.23.3           py39h31eccc5_0  
openh264                  2.1.1                h780b84a_0    conda-forge
openssl                   1.1.1q               h7f8727e_0  
packaging                 21.3               pyhd3eb1b0_0  
pandas                    1.4.4            py39h6a678d5_0  
pcre                      8.45                 h295c915_0  
pillow                    9.2.0            py39hace64e9_1  
pip                       22.2.2           py39h06a4308_0  
ply                       3.11             py39h06a4308_0  
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyg                       2.1.0           py39_torch_1.12.0_cu116    pyg
pyopenssl                 22.0.0             pyhd8ed1ab_1    conda-forge
pyparsing                 3.0.9            py39h06a4308_0  
pyqt                      5.15.7           py39h6a678d5_1  
pyqt5-sip                 12.11.0          py39h6a678d5_1  
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.9.13               haa1d7c7_2  
python-dateutil           2.8.2              pyhd3eb1b0_0  
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.12.1          py3.9_cuda11.6_cudnn8.3.2_0    pytorch
pytorch-cluster           1.6.0           py39_torch_1.12.0_cu116    pyg
pytorch-mutex             1.0                        cuda    pytorch
pytorch-scatter           2.0.9           py39_torch_1.12.0_cu116    pyg
pytorch-sparse            0.6.15          py39_torch_1.12.0_cu116    pyg
pytz                      2022.1           py39h06a4308_0  
qt-main                   5.15.2               h327a75a_7  
qt-webengine              5.15.9               hd2b0992_4  
qtwebkit                  5.212                h4eab89a_4  
readline                  8.2                  h5eee18b_0  
requests                  2.28.1             pyhd8ed1ab_1    conda-forge
scikit-learn              1.1.2            py39h6a678d5_0  
scipy                     1.9.1            py39h14f4228_0  
setuptools                63.4.1           py39h06a4308_0  
sip                       6.6.2            py39h6a678d5_0  
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.39.3               h5082296_0  
threadpoolctl             2.2.0              pyh0d69192_0  
tk                        8.6.12               h1ccaba5_0  
toml                      0.10.2             pyhd3eb1b0_0  
torchaudio                0.12.1               py39_cu116    pytorch
torchvision               0.13.1               py39_cu116    pytorch
tornado                   6.2              py39h5eee18b_0  
tqdm                      4.64.1           py39h06a4308_0  
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzdata                    2022e                h04d1e81_0  
urllib3                   1.26.11            pyhd8ed1ab_0    conda-forge
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.2.6                h5eee18b_0  
zlib                      1.2.13               h5eee18b_0  
zstd                      1.5.2                ha4553b6_0 

Upvotes: 0

Related Questions