Pytorch_geometric: Can't install torch-(scatter|sparse|cluster|spline-conv)

Created on 30 Nov 2020  路  9Comments  路  Source: rusty1s/pytorch_geometric

馃摎 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

  • [x] I followed the installation guide.
  • [x] 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

Most helpful comment

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.

All 9 comments

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: https://github.com/pypa/pip/issues/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'

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.

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.

Good solution, @rusty1s! Thanks again.

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?

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?

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>

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

Was this page helpful?
0 / 5 - 0 ratings