Google Colab 上的 PyTorch Geometric CUDA 安装问题
PyTorch Geometric CUDA installation issues on Google Colab
我正在使用 Google Colab 开发 PyTorch Geometric 项目以获得 CUDA 支持。由于它的库默认不存在,我 运行:
!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
最近导入torch_geometric时,由于版本升级,出现CUDA版本不匹配的提示:
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.
为了解决这个问题,我尝试将 conda 用于特定的 CUDA 版本:
!conda install pytorch==1.4.0 cudatoolkit=10.0 -c pytorch
然而,在 运行ning print(torch.version.cuda)
上,我得到 10.1 作为输出,而不是我想要的 10.0。
这是最近的一个错误,因为它在上周没有抛出这个问题。有解决此问题的最佳做法吗?
试试这个
!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
问题可以通过评论解决:
!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
我们还有其他解决方案吗?
您可能想尝试以下操作,看看是否可以解决 "pytorch-geometric" 中的 CUDA 版本控制错误问题:
- apt-get --purge remove "cublas" "cuda*"
- 重启
- 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 安装 cuda-10-1
- python -c "import torch; print(torch.version.cuda)"
10.1
- nvcc --version
Cuda compilation tools, release 10.1, V10.1.243
根据我的分析,火炬几何给 cuda 11 和 pytorch 1.7.0 带来了错误
请安装pytorch 1.6和amd cuda 10.2并执行以下
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
这是我在合作实验室中用于安装 PyTorch 几何相关依赖项的最新代码命令。
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
你可以在pytorch geometric官方网站上找到示例colab notebooks
https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html
这是我在同一网站上使用的内容。发布之日正在处理中。
!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
我正在使用 Google Colab 开发 PyTorch Geometric 项目以获得 CUDA 支持。由于它的库默认不存在,我 运行:
!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
最近导入torch_geometric时,由于版本升级,出现CUDA版本不匹配的提示:
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.
为了解决这个问题,我尝试将 conda 用于特定的 CUDA 版本:
!conda install pytorch==1.4.0 cudatoolkit=10.0 -c pytorch
然而,在 运行ning print(torch.version.cuda)
上,我得到 10.1 作为输出,而不是我想要的 10.0。
这是最近的一个错误,因为它在上周没有抛出这个问题。有解决此问题的最佳做法吗?
试试这个
!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
问题可以通过评论解决:
!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
我们还有其他解决方案吗?
您可能想尝试以下操作,看看是否可以解决 "pytorch-geometric" 中的 CUDA 版本控制错误问题:
- apt-get --purge remove "cublas" "cuda*"
- 重启
- 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 安装 cuda-10-1
- python -c "import torch; print(torch.version.cuda)"
10.1
- nvcc --version
Cuda compilation tools, release 10.1, V10.1.243
根据我的分析,火炬几何给 cuda 11 和 pytorch 1.7.0 带来了错误
请安装pytorch 1.6和amd cuda 10.2并执行以下
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
这是我在合作实验室中用于安装 PyTorch 几何相关依赖项的最新代码命令。
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
你可以在pytorch geometric官方网站上找到示例colab notebooks https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html
这是我在同一网站上使用的内容。发布之日正在处理中。
!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