Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue installing software: "UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage." #2

Open
HenryCarr98 opened this issue Dec 19, 2024 · 16 comments

Comments

@HenryCarr98
Copy link

HenryCarr98 commented Dec 19, 2024

I would like to install a package called KGWAS and run its demo code https://github.com/snap-stanford/KGWAS/blob/master/demo/kgwas_101.ipynb. I have installed it and all its dependencies , however, when I test it, it always returns me with an error message (attached below). Would you please help me with this issue?

Thank you very much!

python
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('../')
>>>
>>> from kgwas import KGWAS, KGWAS_Data
/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/torch_sparse/_convert_cpu.so: undefined symbol: __kmpc_fork_call
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/kgwas/_init_.py", line 2, in <module>
from .kgwas import KGWAS
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/kgwas/kgwas.py", line 22, in <module>
from .model import HeteroGNN
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/kgwas/model.py", line 7, in <module>
from .conv import GATConv
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/kgwas/conv.py", line 7, in <module>
from torch_sparse import SparseTensor, set_diag
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/torch_sparse/_init_.py", line 18, in <module>
torch.ops.load_library(spec.origin)
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/torch/_ops.py", line 1350, in load_library
ctypes.CDLL(path)
File "/home/.conda/envs/kgwas_gpu/lib/python3.10/ctypes/_init_.py", line 374, in _init_
self._handle = _dlopen(self._name, mode)
OSError: /home/.conda/envs/kgwas_gpu/lib/python3.10/site-packages/torch_sparse/_convert_cpu.so: undefined symbol: __kmpc_fork_call
>>> data = KGWAS_Data(data_path = './data/')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'KGWAS_Data' is not defined
>>> data.load_kg()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data' is not defined
@HenryCarr98
Copy link
Author

Hello, just pinging this issue to see if there are any updates? Cheers.

@kexinhuang12345
Copy link
Collaborator

Hi Henry, seems like your pyg installation has errors.

can you try to import torch-sparse and see if it has errors independent of the KGWAS package?

have you followed this https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html. notice that you will need to make sure your cuda version is correct.

Also, looks like the error says that undefined symbol: __kmpc_fork_call. which is typically associated with OpenMP. This issue usually arises due to a mismatch between the installed libraries or missing OpenMP support. Ensure that OpenMP is installed on your system.

@HenryCarr98
Copy link
Author

Hello! Yes I can confirm I followed those linked instructions. This is what I get when I import torch-sparse. And yes, I double checked and openMP is enabled.

python -c "import torch; print(torch.__version__)"
2.5.1+cu124

@kexinhuang12345
Copy link
Collaborator

i see - can you try from torch_sparse import coalesce?

@HenryCarr98
Copy link
Author

Hi, doing so returns

python -c "from torch_sparse import coalesce"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/__init__.py", line 39, in <module>
    from .storage import SparseStorage  # noqa
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/storage.py", line 7, in <module>
    from torch_sparse.utils import Final, index_sort
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/utils.py", line 5, in <module>
    import torch_sparse.typing
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/typing.py", line 2, in <module>
    import pyg_lib  # noqa
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/pyg_lib/__init__.py", line 34, in <module>
    load_library('libpyg')
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/pyg_lib/__init__.py", line 31, in load_library
    torch.ops.load_library(spec.origin)
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch/_ops.py", line 1350, in load_library
    ctypes.CDLL(path)
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /rds/user/username/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/libpyg.so)

@kexinhuang12345
Copy link
Collaborator

yes, looks like the pyg is not installed correctly. can you try re-install the pyg and related package? you can use the pip version, which i personally found it more bug-free.

For example, you will need to make sure that the pytorch, OS, and cuda version match with what you have.

For example, for pytorch 2.5, linux and cuda = 12.4, install pytorch first and then do:

pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.5.0+cu124.html

@HenryCarr98
Copy link
Author

HenryCarr98 commented Dec 31, 2024

Thank you. So I have

pip list | grep torch
torch                    2.5.1+cu124
torch_cluster            1.6.3+pt25cu124
torch-geometric          2.6.1
torch_scatter            2.1.2+pt25cu124
torch_sparse             0.6.18+pt25cu124
torch_spline_conv        1.2.2+pt25cu124
torchaudio               2.5.1+cu124
torchvision              0.20.1+cu124

And I followed your install steps as well as those from https://stackoverflow.com/questions/78286355/i-cant-find-pytorch-and-cudnn-version-for-cuda-12-4-which-versions-can-i-downl to force the versions I need but still returns

(pytorch3) [hc@dell ]$ python -c "import torch; print(torch.__version__)"
2.5.1+cu124
(pytorch3) [hc@dell ]$ python -c "import torch; print(torch.version.cuda)"
12.4

But doing so still gives

python -c "from torch_sparse import coalesce"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/__init__.py", line 39, in <module>
    from .storage import SparseStorage  # noqa
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/storage.py", line 7, in <module>
    from torch_sparse.utils import Final, index_sort
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/utils.py", line 5, in <module>
    import torch_sparse.typing
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch_sparse/typing.py", line 2, in <module>
    import pyg_lib  # noqa
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/pyg_lib/__init__.py", line 34, in <module>
    load_library('libpyg')
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/pyg_lib/__init__.py", line 31, in load_library
    torch.ops.load_library(spec.origin)
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/torch/_ops.py", line 1350, in load_library
    ctypes.CDLL(path)
  File "/home/username/rds/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /rds/user/username/hpc-work/miniconda3/envs/pytorch2/lib/python3.10/site-packages/libpyg.so)

@HenryCarr98
Copy link
Author

HenryCarr98 commented Dec 31, 2024

I also ran

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jul_14_19:41:19_PDT_2021
Cuda compilation tools, release 11.4, V11.4.100
Build cuda_11.4.r11.4/compiler.30188945_0

And

gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

as well as

ldd --version
ldd (GNU libc) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Let me know if any of this helps.

I purged all packages and installed from scratch but to no avail, since

TOOLKIT_CUDA_VERSION=cu114 pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/$TOOLKIT_CUDA_VERSION
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/
Collecting torch
  Downloading https://download.pytorch.org/whl/cu124/torch-2.5.1%2Bcu124-cp313-cp313-linux_x86_64.whl (908.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 908.2/908.2 MB 24.2 MB/s eta 0:00:00
Collecting torchvision
  Downloading https://download.pytorch.org/whl/torchvision-0.2.0-py2.py3-none-any.whl (48 kB)
ERROR: Could not find a version that satisfies the requirement torchaudio (from versions: none)
ERROR: No matching distribution found for torchaudio

@kexinhuang12345
Copy link
Collaborator

yeah looks like your cuda version is 11.4, which is not compatible. can you upgrade your cuda version to the 11.8/12.1/12.4?

@HenryCarr98
Copy link
Author

Happy new year! Hmm I had a feeling this would be the case. It's a centrally managed cluster and I don't have permissions to do that unfortunately. Does that mean we're pretty much out of luck?

@abearab
Copy link

abearab commented Jan 4, 2025

@HenryCarr98 I had some luck installing KGWAS by installing dependencies through conda, see #1. Maybe that helps?

@HenryCarr98
Copy link
Author

Hello @abearab and thanks for your message. Could you just confirm how exactly you did that?

@abearab
Copy link

abearab commented Jan 4, 2025

you may start with this:

conda env create -f https://raw.githubusercontent.com/abearab/KGWAS/refs/heads/master/environment.yml

@HenryCarr98
Copy link
Author

Ah great, looks good thank you. Does this fix help with the CUDA compatibility issues? Cheers

@abearab
Copy link

abearab commented Jan 4, 2025

Ah great, looks good thank you. Does this fix help with the CUDA compatibility issues? Cheers

Hopefully! The goal is conda will try to install compatible versions of these dependencies including torch_sparse. I don't have access to a CUDA GPU at the moment to test it myself. You can give it a try.

@HenryCarr98
Copy link
Author

Perfect, I'll give this a try. I'll let you know what the results are. Cheers and happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants