Anaconda中安装Pytorch 速度太慢解决办法

本文参考:

​​​​​​Anaconda中安装Pytorch 速度太慢解决办法_ 蜗牛在听雨的博客-CSDN博客_conda install pytorch太慢怎么办 【陆续排坑】解决conda下载速度慢的问题:更换国内源_Xiao_Spring的博客-CSDN博客_conda更改下载源

https://blog.csdn.net/weixin_51484460/article/details/122179000https://blog.csdn.net/kxqt233/article/details/121167753

使用

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

安装pytorch时,其中’-c pytorch’意思是使用pytorch官方源,这很慢。所以要换用国内的源进行安装。

打开终端输入

conda config --show

就能看到anaconda的源了。

Anaconda中安装Pytorch 速度太慢解决办法

首先添加源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
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 --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
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/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
设置搜索时显示通道地址 从channel中安装包时显示channel的url,这样就可以知道包的安装来源
conda config --set show_channel_urls yes

或者修改.condarc配置文件。

将配置文件中通道channels下的” -defaults“去掉,防止使用默认源。

Anaconda中安装Pytorch 速度太慢解决办法

再安装,去掉’-c pytorch’

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

Anaconda中安装Pytorch 速度太慢解决办法

可以看到安装包后面是国内镜像源。如果没有显示源那一列,那是因为 conda config –set show_channel_urls yes没有设置为yes。

还原anaconda官方下载源,使用即可

conda config --remove-key channels

清华源连接失败原因与解决 CondaHTTPError SSLError

解决方案
在我查阅了多篇博客,尝试了多种方案之后,终于找到两种解决方案:

在命令行中输入conda config –set ssl_verify false修改设置,或者在文件~/.condarc末尾添加一行方法一:ssl_verify: false(有则修改即可)
方法二:将https改成http
方法三:换回官方源

原因分析
https协议比http协议多了SSL,TLS等验证和加密的阶段,可能是在与清华源进行SSL验证的过程中会出问题,因此需要关掉SSL验证,或者改用http协议。但是使用SSL验证是有助于保障传输过程的可靠性的。

Original: https://blog.csdn.net/abc1831939662/article/details/123462507
Author: 3DYour
Title: Anaconda中安装Pytorch 速度太慢解决办法

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/706819/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球