1、查看自己的設備對應的cuda版本
(1)打開NVIDIA控制面板
(2)點擊“幫助”,如下圖:
(3)點擊“系統信息”--->“組件”可以看到下圖,CUDA版本是10.2:
2、在官網(https://pytorch.org/)上查看對應的版本
從下圖可以看到紅線標注的是需要運行的命令。但是,如果直接運行將會特別慢,一是文件本身比較大,二是外網安裝。因此選擇清華鏡像源安裝。
3、安裝步驟:
(1)更換鏡像源
在命令行中輸入下述命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
(2)安裝相應的pytorch版本
conda install pytorch torchvision cudatoolkit=10.2 (版本號從https://pytorch.org/上,查找對應版本)