1. 创建新环境
我习惯使用 python 版本 3.6.2
conda create -n name python=3.6.2
2. 下载pytorch
- pytorch官网
- 找到合适的版本:pytorch 1.7.1 + cuda 11.0
3. 搭建 torch_geometric 环境
- 我使用的里本地安装
- 网址:https://pytorch-geometric.com/whl/torch-1.7.1.html
- 先确定了自己的 cuda 、 pytorch以及python版本:
- cuda:11.0
- pytorch:1.7.1
- python:3.6.2
- 打开网址从里面找:一定要对应好版本
- torch-scatter
- torch-sparse
- torch-cluster
- torch-spline-conv
- 四个动下下载好,打开终端,使用命令:
- pip install pkg-name
- 下载torch-geometric:
- pip install torch-geometric
- 验证是否安装好,利用如下代码验证是否安装好:
import torch
import math
from torch_geometric.nn import MessagePassing
from torch_geometric.nn import GATConv
from torch_geometric.utils import add_self_loops, degree
from torch_geometric.datasets import Planetoid
import ssl
import torch.nn.