首先进入要安装torch的环境,没有就先创建一个,例如使用conda
进入终端,使用命令创建新环境
conda create -n name python=*.**
成功后激活环境
conda activate torch
进入浏览器pytorch官网
下滑至install pytorch,选择对应版本
复制pip代码,例如我是
pip3 install torch torchvision torchaudio
进入刚才的终端安装,使用清华源加速安装只需将安装与句后面加
-i https://pypi.tuna.tsinghua.edu.cn/simple 即
pip3 install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple