gpt4 book ai didi

谷歌colab上的pytorch几何 "Detected that PyTorch and torch_sparse were compiled with different CUDA versions"

转载 作者:行者123 更新时间:2023-12-03 21:57:20 25 4
gpt4 key购买 nike

我是 pytorch geometry 的新手,尝试将其安装到我的计算机上但失败了,所以我尝试在 Google Colab 上运行代码。根据上一个问题(这对我没有帮助,我不确定是不是同样的问题):

PyTorch Geometric CUDA installation issues on Google Colab

我做了:

!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

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

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

他们打印:
Successfully installed torch-cluster-1.5.4

Successfully installed torch-scatter-2.0.4 torch-sparse-0.6.1 torch-spline-conv-1.2.0

但是,当我尝试运行时
import torch_geometric.datasets as datasets

我得到:
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 0.0. Please reinstall the torch_sparse that matches your PyTorch install.

任何帮助将不胜感激。

最佳答案

我想出了以下应该在 Colab 上安装 PyTorch Geometric 及其依赖项的代码片段:
https://gist.github.com/ameya98/b193856171d11d37ada46458f60e73e7

# Add this in a Google Colab cell to install the correct version of Pytorch Geometric.
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

关于谷歌colab上的pytorch几何 "Detected that PyTorch and torch_sparse were compiled with different CUDA versions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61297150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com