- 創建虛擬環境
爲pytorch創建一個虛擬環境,這是推薦的做法,這樣在創建其他環境如tensorflow時,就不會互相沖突。在終端輸入:
conda create -n pytorch python=3.6
這就創建了一個名爲pytorch,python版本爲3.6的虛擬環境。於是我們可以把Pytorch安裝在這個環境下面。首先我們激活這個環境:source activate pytorch
source activate pytorch
Pythorch官網:https://pytorch.org/get-started/previous-versions/
- 注意:官網上的命令行要把末尾-c pytorch刪掉纔會用清華源。
例如:conda install pytorch==1.2.0 torchvision == 0.4.0
配置清華源:
https://blog.csdn.net/hktxt/article/details/82111203
配置:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
查看:
cat ~/.condarc