1.根据自己的cuda 版本安装torch
# win、Linux
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
2.查看pip源
pip config list
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
3.pip更新
pip install --upgrade pip
4.Pytorch 安装检测
import torch
torch.__version__ # 查看pytorch版本
torch.cuda.is_available() # 判断pytorch是否支持GPU加速
torch.version.cuda # 查看CUDA版本
torch.backends.cudnn.version() # 查看cuDNN版本
torch.cuda.get_device_name(0) # 查看显卡类型
https://pytorch.org/get-started/locally/