1、ananconda环境配置
在anaconda中创建一个虚拟环境:
conda create -n your_env_name python=X.X (python版本一般选3.6或以上版本)
删除虚拟环境:
conda remove -n your_env_name --all
2、配置清华源用于加速
清华源anconda中pytorch 和torchvision的对应关系
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
添加清华源:
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
添加第三方conda源:
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、安装pytorch和torchvision
安装pytorch和torchvision时要注意与电脑上cuda版本的匹配关系,不同的pytorch版本对应不同的cuda版本,可通过以下链接查找其版本对应关系:
https://pytorch.org/get-started/previous-versions/
安装 pytorch torchvision 时后面不要添加-c pytorch,去掉-c pytorch,安装的时候才会默认从清华源下载相应的包速度会很快,否则会从官方网站下载会很慢:
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0