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

pip install not working with torch==2.3.0 #223

Open
hsharsh opened this issue Jul 29, 2024 · 3 comments
Open

pip install not working with torch==2.3.0 #223

hsharsh opened this issue Jul 29, 2024 · 3 comments

Comments

@hsharsh
Copy link

hsharsh commented Jul 29, 2024

I am trying to create a torch repo which has a C++ backend and I wanted to use pytorch_cluster as a reference for it. I have installed pytorch_cluster with pip from the cloned repo

pip install torch==2.3.0
pip install .

But when I try to import pytorch_cluster, it seems like there are some discrepancies with the installation?

Python 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch_cluster
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/hsharsh/envs/torch_cluster/lib/python3.11/site-packages/torch_cluster/__init__.py", line 18, in <module>
    torch.ops.load_library(spec.origin)
  File "/Users/hsharsh/envs/torch_cluster/lib/python3.11/site-packages/torch/_ops.py", line 1032, in load_library
    ctypes.CDLL(path)
  File "/opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: dlopen(/Users/hsharsh/envs/torch_cluster/lib/python3.11/site-packages/torch_cluster/_version_cpu.so, 0x0006): Symbol not found: __ZN5torch3jit17parseSchemaOrNameERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEb
  Referenced from: <615DC186-B48E-343A-9ED1-B43018EB4628> /Users/hsharsh/envs/torch_cluster/lib/python3.11/site-packages/torch_cluster/_version_cpu.so
  Expected in:     <2A8DB508-8AAF-3FF1-BDFE-9EF17CC2B482> /Users/hsharsh/envs/torch_cluster/lib/python3.11/site-packages/torch/lib/libtorch_cpu.dylib

When I try the same thing with torch==2.4.0, it seems to work fine. The problem here is that I am also going to use torch_geometric as dependency in my library but the wheels for torch==2.4.0 don't exist for torch_geometric, as that version is not supported yet.

Environment details:
Python: 3.11.9
OS: Darwin Kernel Version 23.5.0
pip: 24.0

@rusty1s
Copy link
Owner

rusty1s commented Jul 30, 2024

If you are switching between PyTorch versions, did you make sure to correctly uninstall all existing installations of torch-cluster and re-install them? Usually, an error like Symbol not found: __ZN5torch3jit17parseSchemaOrNameERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEb means that torch-cluster is build on a different PyTorch version than the one you are running it on.

@hsharsh
Copy link
Author

hsharsh commented Jul 30, 2024

I definitely am running a fresh venv for the install. But your comment got me thinking that this might be a problem with pyproject.toml which was recently added to fix the torch dependency issue for setup. If I understand this correctly, this probably installs torch==2.4.0 as the build dependency.

[build-system]
requires = ["setuptools", "torch"]
build-backend = "setuptools.build_meta"

If I specify the version of torch to use, everything seems to work fine:

[build-system]
requires = ["setuptools", "torch==2.3.0"]
build-backend = "setuptools.build_meta"

Maybe it would be nice to specify the version of torch being used for the build automatically but I don't know if this is something you need/want.

@stslxg-nv
Copy link
Contributor

I had to use the --no-build-isolation flag to use the preinstalled pytorch.

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