首先在官网的以前版本中,根据自己的cuda版本找到要安装的pytorch: Previous PyTorch Versions | PyTorch
我的cuda是11.6,根据官网上对应的版本 利用pip进行安装,同时在安装命令后加上(换源更快):
-i https://pypi.tuna.tsinghua.edu.cn/simple some-package
# CUDA 11.6
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116