检查自己的python版本、cuda版本、torch和 torchvision 版本是否兼容
兼容性查看地址:
兼容性查看地址torchvision · PyPI
寻找对应的torch和 torchvision 版本下载地址https://download.pytorch.org/whl/torch_stable.html
例:cuda12.1,python 3.9,torch2.1.1,win
例:cuda12.1,python 3.9,torchversion 0.16.0,win
下载到本地
安装前先卸载原有版本
pip uninstall torch
pip uninstall torchvision
cd到下载目录下pip安装
pip install torch-2.1.0+cu121-cp39-cp39-win_amd64.whl
pip install torchvision-0.16.1+cu121-cp39-cp39-win_amd64.whl
成功!
torch.cuda.device_count()
>>1