conda 安装pytorch 速度慢或者失败的问题

以安装cuda版本为11.1的pytorch为例,官网指明的conda安装命令为:

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

 但是安装的时候可能会报HTTP Error的错误。

解决方法:更改conda的镜像源

先输入下面的命令查看此时的镜像源

conda config --show-sources

如果存在镜像源,上面会提示镜像源的地址xxxx/condarc

如果之前未设置镜像源,也就不存在镜像源文件。随便输入一条命令修改镜像源文件如

conda config --set show_channel_urls yes 

就会自动创建镜像源文件 。此时再按照上面查看镜像源的命令拿到镜像源的地址xxxx/condarc

打开镜像源文件进行修改:

gedit xxxx/condarc

随便选择一个国内的镜像源写入condarc文件并保存。

国内常见的镜像源:

北外镜像:
show_channel_urls: true
channels:
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
  - defaults

清华镜像:
show_channel_urls: true
channels:
- https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- defaults

中科大镜像:
show_channel_urls: true
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
- https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
- defaults

上海交大镜像:
show_channel_urls: true
channels:
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
- defaults

重新安装pytorch,输入

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1

记得复制官网上面的conda命令时候不要带上 -c pytorch -c conda-forge。 -c指的是使用的下载地址,带上了-c则设置的镜像源无效。

在下载的时候仍旧很慢,报错HTTTP ERROR 000

以清华源为例,下载的时候会报错,因为cudatoolkit=11.1的版本在清华源上是没有的。尝试用北外的源下载11.1版本的cudatoolkit。

conda install cudatoolkit=11.1 -c https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge

下载其他的可以用清华源:

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值