一、找到合適的安裝方式
pytorch官網:https://pytorch.org/
二、安裝命令
pip --default-timeout=100 install torch torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
或者
conda install pytorch torchvision -c https://pypi.mirrors.ustc.edu.cn/simple
後面的是鏡像,當然也可以採用其他源,網上很多,在這裏不再陳述。或者用以下命令
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0
三、卸載命令
pip uninstall torch