解决pytorch安装过程中下载总是出错的问题

pytorch官网

1.安装环境创建

这里介绍使用anaconda的环境创建过程。打开anaconda,选择environment,点击create,输入环境名称,对应python版本,点击create。
在这里插入图片描述

修改镜像源

在C盘用户目录下有个.condarc的文件,只要修改里面的参数即可,下面提供以下本人修改后的,这里换成了清华源,别的镜像源也一样修改即可。

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
ssl_verify: true
remote_read_timeout_secs: 600.0

除了直接暴力修改.condarc文件外,你也可以使用终端命令进行修改:

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/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

对于pytorch,需要加入新的源

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

注意一会儿安装pytorch库的时候,记得去掉结尾的 -c pytorch 不然会影响安装的速度。

设置时间参数:

conda config --set remote_read_timeout_secs 600.0

2.conda命令安装

进入pytorch官网,选择下述专栏,查找对应的下载命令。
比如,cuda10.1对应的pytorch版本的下载命令:conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1 -c pytorch
直接在创建好的环境终端中输入所调用下载命令。
在这里插入图片描述
在这里插入图片描述

3.本地安装

有时候上面的安装会遇到报错:
在这里插入图片描述

受网速影响,即使是进行换源,设置时间,也会一直会安装失败,这时候就需要我们使用本地安装的方法。
进入pytorch下载网址:link.选择对应的安装版本进行本地下载。

本人下载的是pytorch1.5.0对应着python3.6的版本,如下图:
在这里插入图片描述
等待下载完成。

(进入之前建好的环境中,这里我配置另外一个环境)打开终端进入下载文件所在文件夹,接着输入命令pip install torch-1.5.0+cu101-cp36-cp36m-win_amd64.whl ,等待安装完成即可。
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小屋*

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值