1. 检查你的cuda版本,cuda向下兼容:
nvidia-smi
2. torch轮子下载网址:download.pytorch.org/whl/torch_stable.html
cu121对应cuda12.1版本;torch-2.1.2对应torch2.1.2版本;cp3.8对应python3.8版本
3. torch和torchvision的版本对应关系:github官方网址:
pytorch/vision: Datasets, Transforms and Models specific to Computer Vision (github.com)
4. 进入conda虚拟环境:
conda activate pytorch
pytorch替换为你的虚拟环境名
5. pip安装torch:
输入pip install 后,把你下载好的轮子文件拖进去,如:
pip install D:\torchvision-0.16.2+cu121-cp38-cp38-win_amd64.whl
pip install D:\torchvision-0.16.2+cu121-cp38-cp38-win_amd64.whl