Pytorch_geometric: OSError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found

Created on 3 Mar 2020  路  4Comments  路  Source: rusty1s/pytorch_geometric

馃悰 Bug

import Batch from torch_geometric fails with _scatter.so error.
N.b. one simple fix could be $pip install libgcc (works with py < 3.8)

Error stack (short):
OSError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_scatter/_scatter.so)


from torch_geometric.data import Batch
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_geometric/data/__init__.py", line 1, in
from .data import Data
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_geometric/data/data.py", line 7, in
from torch_sparse import coalesce
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_sparse/__init__.py", line 41, in
from .storage import SparseStorage
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_sparse/storage.py", line 7, in
from torch_scatter import segment_csr, scatter_add
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_scatter/__init__.py", line 24, in
from .scatter import (scatter_sum, scatter_add, scatter_mean, scatter_min,
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_scatter/scatter.py", line 9, in
torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
File "anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch/_ops.py", line 106, in load_library
ctypes.CDLL(path)
File "anaconda3/envs/pytorch-geometric/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)

OSError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by anaconda3/envs/pytorch-geometric/lib/python3.8/site-packages/torch_scatter/_scatter.so)

Environment

  • OS:
    NAME="Springdale Linux"
    VERSION="7.7 (Verona)"
    ID="rhel"
    ID_LIKE="fedora"
    VERSION_ID="7.7"
    PRETTY_NAME="Springdale Linux 7.7 (Verona)"
  • Python version: 3.8
  • PyTorch version: 1.4.0
  • GCC version: gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
  • CUDA/cuDNN version: 10.1,

    define CUDNN_MAJOR 7

define CUDNN_MINOR 3

define CUDNN_PATCHLEVEL 0

  • nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2019 NVIDIA Corporation
    Built on Wed_Apr_24_19:10:27_PDT_2019
    Cuda compilation tools, release 10.1, V10.1.168

Most helpful comment

For anyone else facing the issue, this is how I did it

conda install -c omgarcia gcc-6 # install GCC version 6
conda install libgcc            # install conda gcc tools

# make sure that you see GLIBCXX_3.4.xx on the list (which it could not find before)
strings <conda-env-path>/lib/libstdc++.so.6 | grep GLIBCXX

# add it to library paths
export LD_LIBRARY_PATH=<conda-env-path>/lib:$LD_LIBRARY_PATH

python -c "import torch; print(torch.cuda.is_available())"  # make sure CUDA is available
python -c "import torch; print(torch.version.cuda)"         # identify pytorch's CUDA version
nvcc --version                                              # identify system wide CUDA compiler version

# if the nvcc version does not match with the pytorch version, then
# go to the path where CUDA is installed (assuming `ls /usr/local/`) 
# and identify the correct CUDA directory. 
# Add it to the system-wide paths (assuming CUDA 10.1)
export PATH=/usr/local/cuda-10.1/bin:$PATH
export CPATH=/usr/local/cuda-10.1/include:$CPATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH

# (OPTIONAL) again make sure that both CUDA versions are the same
python -c "import torch; print(torch.version.cuda)"
nvcc --version

# set the CUDA version as an environment variable.
# Valid options are: cpu, cu92, cu100 or cu101
CUDA=cu101

# now install the libraries
pip install torch-scatter==latest+${CUDA} torch-sparse==latest+${CUDA} -f https://s3.eu-central-1.amazonaws.com/pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-cluster
pip install torch-spline-conv
pip install torch-geometric

All 4 comments

@raeidsaqur I am facing the same issue. How did you resolve it?

Hi @rahular, make sure whatever environment is set, the gnu c compiler has the requried version of GLIBCXX. For e.g. do:
$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
or
$ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
If you are using conda, try $ conda install libgcc
Hope that helps.

For anyone else facing the issue, this is how I did it

conda install -c omgarcia gcc-6 # install GCC version 6
conda install libgcc            # install conda gcc tools

# make sure that you see GLIBCXX_3.4.xx on the list (which it could not find before)
strings <conda-env-path>/lib/libstdc++.so.6 | grep GLIBCXX

# add it to library paths
export LD_LIBRARY_PATH=<conda-env-path>/lib:$LD_LIBRARY_PATH

python -c "import torch; print(torch.cuda.is_available())"  # make sure CUDA is available
python -c "import torch; print(torch.version.cuda)"         # identify pytorch's CUDA version
nvcc --version                                              # identify system wide CUDA compiler version

# if the nvcc version does not match with the pytorch version, then
# go to the path where CUDA is installed (assuming `ls /usr/local/`) 
# and identify the correct CUDA directory. 
# Add it to the system-wide paths (assuming CUDA 10.1)
export PATH=/usr/local/cuda-10.1/bin:$PATH
export CPATH=/usr/local/cuda-10.1/include:$CPATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH

# (OPTIONAL) again make sure that both CUDA versions are the same
python -c "import torch; print(torch.version.cuda)"
nvcc --version

# set the CUDA version as an environment variable.
# Valid options are: cpu, cu92, cu100 or cu101
CUDA=cu101

# now install the libraries
pip install torch-scatter==latest+${CUDA} torch-sparse==latest+${CUDA} -f https://s3.eu-central-1.amazonaws.com/pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-cluster
pip install torch-spline-conv
pip install torch-geometric

@rahular great solution, thanks a lot !!

Was this page helpful?
0 / 5 - 0 ratings