1. 先新建虛擬環(huán)境,命名為pytorch,可以命名為自己習(xí)慣的名稱厅瞎。
conda create -n pytorch python=3.6
2. 進(jìn)入該虛擬環(huán)境
conda activate pytorch
3. 去官網(wǎng)選擇合適版本
pytorch官網(wǎng):https://pytorch.org/get-started/locally/
conda install pytorch torchvision cpuonly -c pytorch
使用清華源安裝:
https://blog.csdn.net/werdery/article/details/104866515
在pycharm里面:File-Settings-Project-project interpreter,然后選中
4. 運(yùn)行以下代碼看看是否已經(jīng)安裝成功:
import torch
import torchvision
print(torch.__version__)
報錯:
Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.
It can be downloaded at https://aka.ms/vs/16/release/vc_redist.x64.exe
解決:
安裝VC(https://blog.csdn.net/qq_29750461/article/details/108083764
)