cuda11.7就选cu117
python3.8就选cp38
windows就选win
安装torch
进入官网
https://download.pytorch.org/whl/torch/
搜索
torch-2.0.1+cu117-cp38-cp38-win_amd64.whl
安装torchvision
进入官网
https://download.pytorch.org/whl/torchvision/
搜索
torchvision-0.15.2+cu117-cp38-cp38-win_amd64.whl
安装torchaudio
进入官网
https://download.pytorch.org/whl/torchaudio/
搜索
torchaudio-2.0.2+cu117-cp38-cp38-win_amd64.whl
pip安装
进入下载目录
目录栏输入cmd回车
激活虚拟环境activate py38torch
开始安装
pip install torch-2.0.1+cu117-cp38-cp38-win_amd64.whl
pip install torchvision-0.15.2+cu117-cp38-cp38-win_amd64.whl
pip install torchaudio-2.0.2+cu117-cp38-cp38-win_amd64.whl
不要选错版本,不然会提示:
torchaudio 2.0.2+cu117 requires torch2.0.1, but you have torch 1.13.0+cu117 which is incompatible.
torchvision 0.15.2+cu117 requires torch2.0.1, but you have torch 1.13.0+cu117 which is incompatible .
验证GPU可用
import torch# Check if GPU is available
if torch.cuda.is_available():print("GPU 可用")
else:print("GPU 不可用")