1、添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
2、可以添加额外的库–第三方源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
3、创建虚拟环境
conda create -n $YOUR_NAME$ python=3.6
4、安装pytorch
pip install torch==1.1.0 torchvision==0.3.0 (pip安装,cuda、cudnn需要事先安装好)
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0 (自动安装cuda、cudnn)
这里一定要注意,去掉-c pytorch,安装的时候才会默认从清华源下载相应的包
conda install pytorch torchvision cudatoolkit=9.0
5、如何查看pytorch对应的cuda版本?
打开终端输入:python
输入命令:import torch
再输入:print(torch.version.cuda)