10

I was working on a PyTorch Geometric project using Google Colab for CUDA support. Since it's library isn't present by default, I run:

!pip install --upgrade torch-scatter
!pip install --upgrade torch-sparse
!pip install --upgrade torch-cluster
!pip install --upgrade torch-spline-conv 
!pip install torch-geometric

Recently, while importing torch_geometric, owing to version upgrades, there's a CUDA version mismatch saying:

RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions. PyTorch has CUDA version 10.1 and torch_sparse has CUDA version 10.0. Please reinstall the torch_sparse that matches your PyTorch install.

To solve this, I tried using conda for specific CUDA version as:

!conda install pytorch==1.4.0 cudatoolkit=10.0 -c pytorch

Yet, on running print(torch.version.cuda), I get 10.1 as the output and not 10.0 as I wanted.

This is a recent error since it wasn't throwing up this issue in past week. Any best practice to solve this issue?

Sparky05
  • 4,692
  • 1
  • 10
  • 27
Kanishk Mair
  • 333
  • 1
  • 4
  • 8

6 Answers6

12

From their website

Try this

!pip install torch-geometric \
  torch-sparse==latest+cu101 \
  torch-scatter==latest+cu101 \
  torch-cluster==latest+cu101 \
  -f https://pytorch-geometric.com/whl/torch-1.4.0.html
korakot
  • 37,818
  • 16
  • 123
  • 144
  • **UPDATE**: We must even include torch-spline-conv in the above command to be compatible with the latest version. – Kanishk Mair Mar 03 '20 at 00:12
  • @MdWahiduzzamanKhan, apparently, even torch-cluster has been updated. Use: !pip install torch-cluster==latest+cu101 -f https://pytorch-geometric.com/whl/torch-1.4.0.html This line will even make torch-cluster compatible – Kanishk Mair Apr 04 '20 at 23:58
2

You can find example colab notebooks on the pytorch geometric official website https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html

Here is what I used from the same website. It is working on the date of posting.

!pip install -q torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
!pip install -q torch-sparse -f https://data.pyg.org/whl/torch-1.10.0+cu113.html
!pip install -q git+https://github.com/pyg-team/pytorch_geometric.git
TNS
  • 21
  • 3
  • This seems to duplicate existing answers by and large, can you explain what's different and significant? – tripleee Jan 17 '22 at 13:53
  • None of the solutions given here are working right now. The one given on Pytorch Geometric official website is what worked for me. – TNS Jan 17 '22 at 13:58
1

The issues can be solve with comment:

!pip install torch-scatter==latest+cu101 torch-sparse==latest+cu101 -f https://s3.eu-central-1.amazonaws.com/pytorch-geometric.com/whl/torch-1.4.0.html

Do we have another solution ?

  • Could you please comment how did you solve the issue with this line? Should it be added after !pip install torch-geometric \ torch-sparse==latest+cu101 \ torch-scatter==latest+cu101 \ torch-cluster==latest+cu101 \ -f https://pytorch-geometric.com/whl/torch-1.4.0.html or used instead ? – user48115 Jul 22 '20 at 05:17
0

you might want to try the following to see if this solves your problem with the CUDA versioning error in "pytorch-geometric" :

  1. apt-get --purge remove "cublas" "cuda*"
  2. reboot
  3. sudo curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
  4. sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
  5. sudo apt-get install cuda-10-1
  6. python -c "import torch; print(torch.version.cuda)"

    10.1

  7. nvcc --version

    Cuda compilation tools, release 10.1, V10.1.243

samaujs
  • 1
  • 3
0

As per my analysis torch geometric is giving error for cuda 11 and pytorch 1.7.0

Please install pytorch 1.6 and amd cuda 10.2 and execute below

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.6.0+cu102.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.6.0+cu102.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.6.0+cu102.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.6.0+cu102.html
pip install torch-geometric
tripleee
  • 175,061
  • 34
  • 275
  • 318
0

This is the latest code-command,that I've used on co-lab for installing PyTorch geometry related dependency.

import torch

def format_pytorch_version(version):
  return version.split('+')[0]

TORCH_version = torch.__version__
TORCH = format_pytorch_version(TORCH_version)

def format_cuda_version(version):
  return 'cu' + version.replace('.', '')

CUDA_version = torch.version.cuda
CUDA = format_cuda_version(CUDA_version)

!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
!pip install torch-geometric 
aminulpalash
  • 156
  • 6