conda安装pytorch速度慢或是失败

很服气,就很服气

conda安装pytorch断断续续装了很久,每次都是下载不到10%就报下面的错:

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/pytorch-1.5.1-py3.5_cuda10.2.89_cudnn7.6.5_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.

网上找的解决方案大多是修改conda的下载源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

conda install pytorch torchvision cpuonly -c pytorch

# 但是一定要去掉后面的 -c pytorch。因为命令最后是-c pytorch,所以默认还是从conda源下载,新安装的清华等源没有用上,接下来就是丝滑般安装了

这个方法还是没能解决,仍旧下载安装失败。

后来参考了这篇文章: conda install pytorch 安装缓慢的解决办法

具体步骤是:

1、先在网上下载pytorch的压缩包(上面的直接conda install pytorch即使下载失败,也会给出下载地址的链接),不过我执行这个步骤也挺一波三折的,下载时经常断开,要不断的点击继续下载;

2、将下载好的压缩包解压,放到conda的缓存地址(conda config --show能查看缓存地址,一般是home下.conda/pkgs和anaconda安装路径的pkgs),我是将这两个地方都放了解压后的文件夹;

3、在 anaconda3下载路径的/pkgs 下的 urls.txt 文件内添加此 pytorch package 的下载路径:

4、再次执行conda install pytorch,就可以了。

猜你喜欢

转载自blog.csdn.net/whuzhang16/article/details/115356437