
復制pip的下載地址:
pip3 install torch==1.10.2+cu102 torchvision==0.11.3+cu102 torchaudio===0.10.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
先直接訪問torch的直接下載地址,也就是上邊-f后邊的地址:https://download.pytorch.org/whl/cu102/torch_stable.html
然后找到需要下載的torch .whl文件:
這時候可以開啟代理,大小一個多G,幾分鍾就下完了。
1.進入到下載目錄: cd C:\Users\DELL\Downloads
2.執行安裝命令: pip install torch-1.10.2+cu102-cp38-cp38-win_amd64.whl
3.再執行最先復制的完全安裝命令安裝其他插件:pip3 install torch==1.10.2+cu102 torchvision==0.11.3+cu102 torchaudio===0.10.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
ok,搞定!
linux的話,首先看看你電腦的cuda版本,用nvidia-smi這個命令查一下:
Wed Feb 16 18:02:10 2022
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| NVIDIA-SMI 430.64 Driver Version: 430.64 CUDA Version: 10.1 |
|----------------------------------------------------+----------------------------------------------+-------------------------------------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|==============================+==========================+============================|
| 0 TITAN X (Pascal) Off | 00000000:02:00.0 Off | N/A |
| 91% 89C P2 261W / 250W | 3527MiB / 12194MiB | 95% Default |
+----------------------------------------------------+---------------------------------------------+-------------------------------------------------+
| 1 TITAN X (Pascal) Off | 00000000:81:00.0 Off | N/A |
| 30% 51C P8 10W / 250W | 10MiB / 12196MiB | 0% Default |
+---------------------------------------------------- +--------------------------------------------+-------------------------------------------------+
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|======================================================================================|
| 0 25307 C python 3517 MiB |
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
但首頁我們看到cuda這並沒有10.1的,去以前的版本里查詢:
往下滑看哪些版本支持10.1版本
1.8.1里就有,直接復制這個命令下載就好
另外,上邊說的cuda版本與驅動對應有兼容要求:
簡單看你的驅動大於418就不用管了!如果小於或者不對應的話,需要更新顯卡驅動。
安裝完后,python引入torch,看看先看是否可用:
python
import torch
torch.cuda.is_available()
如果返回True則代表ok了,你可以搞事情了!