pytorch安装问题

在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

安装成功!

  • 26
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值