PyTorch官網:http://pytorch.org/
由於官網各種點擊按鈕沒有反應,只能下載安裝。
下載PyTorch
選擇舊版本安裝
找到所需版本,如上圖所示,下載cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl。其中,0.2.0表示PyTorch版本,cp27表示支持Python2.7,cu80表示支持CUDA 8.0。
安裝PyTorch
進入PyTorch的下載目錄,使用pip命令安裝:
pip install torch-0.2.0.post3-cp27-cp27m-manylinux1_x86_64.whl
或直接從鏈接安裝
pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl
切記:在安裝之前請先將已經安裝的numpy卸載掉,安裝PyTorch過程中會自動安裝numpy,不然會報ImportError: numpy.core.multiarray failed to import錯誤。
安裝torchvision
pip install torchvision
驗證
import torch
import torchvision
print(torch.cuda.is_available())
若驗證通過,則PyTorch已經安裝成功。
參考: