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

Can't install torch-(scatter|sparse|cluster|spline-conv) #1876

Closed
2 tasks done
LucaMarconato opened this issue Nov 30, 2020 · 9 comments
Closed
2 tasks done

Can't install torch-(scatter|sparse|cluster|spline-conv) #1876

LucaMarconato opened this issue Nov 30, 2020 · 9 comments

Comments

@LucaMarconato
Copy link

📚 Installation

Running python -c "import torch; print(torch.__version__)" gives 1.6.0
Running python -c "import torch; print(torch.version.cuda)" gives 10.2.

Yet, with the following:

pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-geometric

I can install only torch-geometric, while for the first 4 packages I get the following error:

...
  File "/data/l989o/miniconda3/envs/spatial_uzh/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 290, in __init__
    wheel_version = Version(wheel.version)
  File "/data/l989o/miniconda3/envs/spatial_uzh/lib/python3.8/site-packages/pip/_vendor/packaging/version.py", line 298, in __init__
    raise InvalidVersion("Invalid version: '{0}'".format(version))
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'latest+cu102'

Environment

  • OS: RETTY_NAME="CentOS Linux 7 (Core)"
  • Python version: 3.8.0
  • PyTorch version: 1.6.0
  • CUDA/cuDNN version: 10.2
  • GCC version: 7.2.0
  • How did you try to install PyTorch Geometric and its extensions (wheel, source): wheel
  • Any other relevant information:

Checklist

  • I followed the installation guide.
  • I cannot find my error message in the FAQ.
  • [/] I set up CUDA correctly and can compile CUDA code via nvcc. Cuda works perfectly with torch, but I don't have nvcc (I am using a machine partly managed by the institute)
  • [/] I do have multiple CUDA versions on my machine. I think yes: nvidia-smi gives 10.2, but I can also use cuda 9.2 with torch, so yes, I guess I have multiple versions installed.

Additional context

@bdice
Copy link
Contributor

bdice commented Dec 1, 2020

It appears this is caused by pip 20.3, which was released today. The new version is stricter and is unable to parse the version string. See also: pypa/pip#9188

Minimal reproduction for the error (requires packaging, which is vendored inside of pip):

>>> from pip._vendor.packaging.version import Version
>>> # "from packaging.version import Version" also works if packaging is installed separately
>>> Version("latest+cu102")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.../python3.8/site-packages/pip/_vendor/packaging/version.py", line 298, in __init__
raise InvalidVersion("Invalid version: '{0}'".format(version))
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'latest+cu102'

Short-term fixes that might help:

  • Install using a pinned version like 2.0.5+cu110 that can be parsed by packaging.version.Version.
  • Downgrade to pip 20.2

Current pinnings as of today (I only checked for torch 1.7.0):

pip install torch-scatter==2.0.5+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-sparse==0.6.8+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-cluster==1.5.8+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-spline-conv==1.2.0+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
pip install torch-geometric

edit: Apologies, my pinning suggestion won't work. The wheel's metadata version (2.0.5) doesn't match the version specifier that includes the platform cpu/cu* tag (2.0.5+cpu). See the error below. The only solution that I see right now is to use pip==20.2.4 or so, until the packaging ecosystem can fix these problems.

ERROR: Requested torch-scatter==2.0.5+cpu from https://pytorch-geometric.com/whl/torch-1.7.0/torch_scatter-2.0.5%2Bcpu-cp38-cp38-linux_x86_64.whl has different version in metadata: '2.0.5'

@rusty1s
Copy link
Member

rusty1s commented Dec 1, 2020

Related to #1875.

@rusty1s
Copy link
Member

rusty1s commented Dec 1, 2020

I'm in the process of providing the correct metadata for pinned wheels. Not yet sure how to handle the latest version prefix. I think that one was very convenient.

@rusty1s
Copy link
Member

rusty1s commented Dec 1, 2020

This is now resolved. You can now install the packages via:

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html

For example, for installing for PyTorch 1.7.0 with CUDA 11.0, type:

pip install torch-scatter torch-sparse torch-cluster torch-spline-conv -f https://pytorch-geometric.com/whl/torch-torch-1.7.0+cu110.html

All "old" links are still intact. You can have a look at all possible combinations here.

@rusty1s rusty1s closed this as completed Dec 1, 2020
@bdice
Copy link
Contributor

bdice commented Dec 1, 2020

Good solution, @rusty1s! Thanks again.

@LucaMarconato
Copy link
Author

Thanks a lot @rusty1s
Only one thing, using those commands some of the wheels get's built on my machine and it takes somethings like 5-10 minutes. Is there a way to have them pre-built?

@rusty1s
Copy link
Member

rusty1s commented Dec 1, 2020

It should only built from source in case it cannot find a suitable wheel for your OS. Does

pip install https://pytorch-geometric.com/whl/torch-1.6.0%2Bcu102/torch_scatter-2.0.5-cp38-cp38-linux_x86_64.whl

work for you?

@LucaMarconato
Copy link
Author

Understood. Yes it installs it immediately.
To install it I ran conda clean --all, and then I have run the following:

conda create -n test0 python=3.8
conda activate test0
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch
pip <command that you posted>

@LucaMarconato
Copy link
Author

I have also tried calling it with --no-cache-dir and again, the installation was immediate.

bennofs added a commit to bennofs/compy-learn that referenced this issue May 6, 2021
Versions like `latest+cpu` are not PEP440-compliant. Starting with version 20.3, pip enforces that versions match the spec.

PyTorch has adapted a new URL scheme to comply with PEP440.
See pyg-team/pytorch_geometric#1876
bennofs added a commit to bennofs/compy-learn that referenced this issue May 13, 2021
Versions like `latest+cpu` are not PEP440-compliant. Starting with version 20.3, pip enforces that versions match the spec.

PyTorch has adapted a new URL scheme to comply with PEP440.
See pyg-team/pytorch_geometric#1876
bennofs added a commit to bennofs/compy-learn that referenced this issue May 13, 2021
Versions like `latest+cpu` are not PEP440-compliant. Starting with version 20.3, pip enforces that versions match the spec.

PyTorch has adapted a new URL scheme to comply with PEP440.
See pyg-team/pytorch_geometric#1876
gsavarela added a commit to gsavarela/dcg that referenced this issue Jun 24, 2022
InvalidVersion error:
---------------------
pip._vendor.packaging.version.InvalidVersion: Invalid version:
'latest+cu102'

Solution:
--------
Downgrade to pip 20.2
[1] pyg-team/pytorch_geometric#1876
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