安裝好anaconda后,安裝pytorch:
(1)使用pip install** ,代替conda install***更方便
(2)需要用到GPU資源的話,要加cuda的內容。linux查看本機cudu版本的命令為:cat /usr/local/cuda/version.txt
(3)知道了cuda的版本,去查看對應torch和torchvision的版本
我的cuda版本是10.0.130,所以我要安裝的pytorch版本是1.1,1.2這些。我選擇1.2版本,那torch對應也是1.2版本,torchvision就選擇0.4.0版本。
(4)直接在shell里輸入:pip install torch==1.2.0 torchvison==0.4.0,回車,等他運行結束
(5)shell鍵入“python”進入python環境,然后輸入“import torch",看看是否成功,”print(torch.cuda.is_available()) ”查看cuda版本是否對應。如果沒有按照上面的版本對應的話,他會返回“False”,對應上了,就返回“True"。