我正在尝试在需要以下内容的集群中运行 Python 脚本:
火炬==1.7.1
火炬稀疏==0.6.8
问题是,当我安装这两个时,torch附带的cuda版本为10.2,而torch-sparse使用集群中的可用版本,即11,因此出现以下错误
Traceback (most recent call last):
File "/home/g.pocas/GraphGONet/scripts/GraphGONet.py", line 6, in <module>
from torch_geometric.data import DataLoader
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_geometric/__init__.py", line 2, in <module>
import torch_geometric.nn
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_geometric/nn/__init__.py", line 2, in <module>
from .data_parallel import DataParallel
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_geometric/nn/data_parallel.py", line 5, in <module>
from torch_geometric.data import Batch
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_geometric/data/__init__.py", line 1, in <module>
from .data import Data
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_geometric/data/data.py", line 8, in <module>
from torch_sparse import coalesce, SparseTensor
File "/home/g.pocas/GraphGONet/venv/lib/python3.9/site-packages/torch_sparse/__init__.py", line 27, in <module>
raise RuntimeError(
RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions. PyTorch has CUDA version 10.2 and torch_sparse has CUDA version 11.2. Please reinstall the torch_sparse that matches your PyTorch install.
我尝试过在没有cuda的情况下安装torch,并且torch稀疏的版本应该与torch 1.7.1兼容,因为我直接从他们提供的轮子安装了它,所以我真的不确定是什么导致了这个问题。
您需要的版本可以通过 pip 安装:
pip install torch-sparse -f https://data.pyg.org/whl/torch-1.7.1+cu102.html