问题
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?
回答1:
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
回答2:
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 ?
回答3:
you might want to try the following to see if this solves your problem with the CUDA versioning error in "pytorch-geometric" :
- apt-get --purge remove "cublas" "cuda*"
- reboot
- sudo curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
- 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
- sudo apt-get install cuda-10-1
- python -c "import torch; print(torch.version.cuda)"
10.1
- nvcc --version
Cuda compilation tools, release 10.1, V10.1.243
来源:https://stackoverflow.com/questions/60236134/pytorch-geometric-cuda-installation-issues-on-google-colab