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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值