pytorch安装问题,conda换清华源

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jiyangsb/article/details/82430794

在ubuntu上安装pytorch,使用官网给出的安装命令:

conda install pytorch torchvision cuda80 -c pytorch

但是总是出现CondaHTTPError:

CondaError: CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://conda.anaconda.org/pytorch/linux-64/cuda80-1.0-h205658b_0.tar.bz2
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.

CondaError: CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://conda.anaconda.org/pytorch/linux-64/cuda80-1.0-h205658b_0.tar.bz2
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.

CondaError: CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://conda.anaconda.org/pytorch/linux-64/cuda80-1.0-h205658b_0.tar.bz2
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.

将anconda的安装源修改为清华的镜像源:

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/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

但是运行命令后发现还是出现同样的错误,后来发现是由于在安装时指定了链接地址导致的,也就是说官方给出的安装命令中多出了一个-c pytorch,所以可以看到使用官方给出的命令后显示如下log:

The following NEW packages will be INSTALLED:

cuda80:      1.0-h205658b_0                     pytorch                                                
cudatoolkit: 8.0-3                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
ninja:       1.7.2-0                            https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pytorch:     0.4.1-py36_cuda8.0.61_cudnn7.1.2_1 pytorch                                                 [cuda80]
torchvision: 0.2.1-py36_1                       pytorch                                                

也就是时说-c pytorch命令使得pytorch的安装源并没有使用我们指定的清华的安装源,去掉这个,使用如下命令即可:

conda install pytorch torchvision cuda80

这事可以看到pytorch使用的安装源变成我们指定的:

The following NEW packages will be INSTALLED:

cuda80:      1.0-h205658b_0                     https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
cudatoolkit: 8.0-3                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free    
ninja:       1.7.2-0                            https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free    
pytorch:     0.4.1-py36_cuda8.0.61_cudnn7.1.2_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch [cuda80]
torchvision: 0.2.1-py36_1                       https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch

安装成功!

————————————————
版权声明:本文为CSDN博主「Jimyang1ssa」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jiyangsb/article/details/82430794


换回默认源:conda config --remove-key channels

在执行conda config 命令的时候
会在当前用户目录下创建 .condarc 文件,可以查看更换源前后该文件内容的变化。
参考: https://blog.csdn.net/sean2100/article/details/80998643
————————————————
版权声明:本文为CSDN博主「甜甜圈Sweety」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qinglingLS/article/details/89363368

你可能感兴趣的:(pytorch,换源)