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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
2、查看镜像源
conda config --show channels
3、遇到的bug
在安装pytorch时发现错误
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirros.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/current_repodata.json>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
'https://mirros.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64'
4、问题解决
使用conda config --remove -key channels指令换回默认源
再次添加新清华镜像源
再次安装pytorch失败
最终妥协使用使用conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch安装成功,应该是清华镜像源没有这个版本的pytorch,他会从清华园下载有的,然后从pytorch官网下载没有torch