1. PyTorch 1.11.0
1.1 cudatoolkit 10.2
2022.8.3
我安装PyTorch用的Python3.8,命令是conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch
这是符合quick start的场景,所以可以直接安装:
conda install pyg -c pyg
1.2 cudatoolkit 11.3
2022.9.1
PyTorch 1.11.0+cu113(命令是:pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113)
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.11.0+cu113.html pip install torch-sparse -f https://data.pyg.org/whl/torch-1.11.0+cu113.html pip install torch-geometric
2. main/nightly版本
2022.8.10
我是因为这个:After T.ToUndirected, the data.is_undirected() is still False · Discussion #5174 · pyg-team/pytorch_geometric 所以需要下main/nightly版本的。
官方GitHub README文件中的安装部分:https://github.com/pyg-team/pytorch_geometric#installation
(先把之前下过的PyG给conda uninstall了)
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.11.0+cu102.html pip install torch-sparse -f https://data.pyg.org/whl/torch-1.11.0+cu102.html pip install pyg-nightly
(请自行替换torch和cuda的版本)
3. 测试安装效果
import torch from torch_geometric.data import Data edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]], dtype=torch.long) x = torch.tensor([[-1], [0], [1]], dtype=torch.float) data = Data(x=x, edge_index=edge_index) print(data)
输出:
my_env/lib/python3.8/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.1 warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}" Data(x=[3, 1], edge_index=[2, 4])
可以看到这里scipy和numpy的版本不合。但是这样我也没有办法!