1、新建環境:
conda create -n pytorch(PyG) python=3.6
2、激活環境
activate pytorch(PyG)
3、安裝pytorch(GPU)版本。
4、檢查pytorch版本與CUDA版本:
>>python -c "import torch; print(torch.__version__)"
>>1.10.1
>>python -c "import torch; print(torch.version.cuda)"
>>10.2
5、安裝pytorch-geometric:
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
其中torch換成自己的torch版本,CUDA換成自己的CUDA版本。
例如,我的實例:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.1+cu102.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.10.1+cu102.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.10.1+cu102.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.10.1+cu102.html
pip install torch-geometric
6、測試:
import torch_geometric.transforms as T
from torch_geometric.nn import GCNConv,ChebConv