栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

下载pytorch的经历(20220514)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

下载pytorch的经历(20220514)

成功安装的过程

本人成功安装pytorch历时两天,尝试过网上各种方法,例如:换清华源,华科源,豆瓣源;使用conda下载,使用pip下载

最后糊里糊涂下载成功,总结成此文章。

网上很多说清华源崩了,所以我尝试其他镜像源,好像也不太行,最后还是用回清华源(不用镜像下载根本跑不动1%的进度条)

  1. 首先换清华源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

  1. 查看换源后的地址

conda config --show channels

  1. 下载完后清除镜像源文件,等成功安装完后用该命令

conda config --remove-key channels

  1. 复制Pytorch网站上的下载地址,换源后要把-c pytoch 删掉

conda install pytorch torchvision torchaudio cudatoolkit=11.3


如果中途断掉了,不要管其他,继续运行以下命令继续下载

conda install pytorch torchvision torchaudio cudatoolkit=11.3

  1. 验证pytorch是否能用

python
import pytorch
print(torch.cuda.is_available())


我的.condarc文件如下

show_channel_urls: true
remote_read_timeout_secs: 1000.0
ssl_verify: false
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults

ssl_verify: false 是为了跳过https的安全验证

https协议比http协议多了SSL,TLS等验证和加密的阶段,可能是在与清华源进行SSL验证的过程中会出问题,因此需要关掉SSL验证,或者改用http协议

如果下载retry好几遍总是超时(或者CondaError:Downloaded bytes did not match Content-Length)
就需要设置这个指令,在prompt命令台,进入制定环境,执行conda config --set remote_read_timeout_secs 1000.0,如果还不行,后面的值可以适当增大一下试试。

其他一些问题 CondaHTTPError: HTTP 000 CONNECTION FAILED for url
  1. 首先执行命令,查看自己的镜像源
    conda config --show channels

  2. 可以首先删除已经存在的镜像源(注:上述三个镜像源无需删除!!!),其他镜像源当然也可以不删除,为了方便建议除了上述三个镜像源都执行删除操作,执行命令
    config --remove channels

    如:conda config --remove channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

  3. 执行命令,添加镜像源

conda config --add channels ​​​​​http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels ​​​​​​http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels ​​​​​​http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

  1. 执行命令,将ssl验证置为false,由于镜像源是http,所以必须取消ssl认证

conda config --set ssl_verify false

  1. 最最最重要的一步!!!将默认镜像删除,执行命令

conda config --remove channels defaults

  1. 设置显示镜像url,可有可无,执行命令

conda config --set show_channel_urls true

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/886405.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号