使用默认 conda 源或者 pip 源安装 PyTorch 时,经常会下载很慢,这里我是用上海交大的上海交通大学 Linux 用户组 软件源镜像服务源来进行加速。
pytorch-wheels 是 PyTorch pip 源的镜像。直接将 Start Locally | PyTorch 中的
https://download.pytorch.org/whl
替换为 https://mirror.sjtu.edu.cn/pytorch-wheels
即可。
使用前最好先把 pip 镜像源也设置一下
pip config set global.index-url https://mirrors.cernet.edu.cn/pypi/web/simple
这里提供几个版本的 PyTorch 对应的安装命令
# 2.3.0+cu118
pip install torch==2.3.0+cu118 torchvision==0.18.0+cu118 torchaudio==2.3.0+cu118 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.3.0+cu121
pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 torchaudio==2.3.0+cu121 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.2.0+cu118
pip install torch==2.2.0+cu118 torchvision==0.17.0+cu118 torchaudio==2.2.0+cu118 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.2.0+cu121
pip install torch==2.2.0+cu121 torchvision==0.17.0+cu121 torchaudio==2.2.0+cu121 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.1.0+cu118
pip install torch==2.1.0+cu118 torchvision==0.16.0+cu118 torchaudio==2.1.0+cu118 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.1.0+cu121
pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 torchaudio==2.1.0+cu121 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html
# 2.0.0+cu118
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 -f https://mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html