【教程】Conda更换镜像源安装pytorch

Windows下Conda安装pytorch换源

我们直接从conda官方或pytorch官方安装pytorch时,由于服务器在国外,速度很慢,或者无法下载/中断,这时候换上国内的镜像源会快很多。

这里给出更换阿里源的例子,其他国内源同理。

配置方法

创建.condarc文件

Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

该文件所在路径通常为C盘/User/用户名/.condarc

配置镜像源

用以下内容替换.condarc文件内容:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.aliyun.com/anaconda/pkgs/main
  - https://mirrors.aliyun.com/anaconda/pkgs/r
  - https://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.aliyun.com/anaconda/cloud
  msys2: https://mirrors.aliyun.com/anaconda/cloud
  bioconda: https://mirrors.aliyun.com/anaconda/cloud
  menpo: https://mirrors.aliyun.com/anaconda/cloud
  pytorch: https://mirrors.aliyun.com/anaconda/cloud
  simpleitk: https://mirrors.aliyun.com/anaconda/cloud

  • 注意,这里网上的其他教程一般是 http,但是可能不好使,改成https就行了。

清除索引缓存

配置完成可运行命令: conda clean -i 清除索引缓存。

使用方式

在下载时,如果不指定特定通道,则会使用上述的默认通道去检索包。

当要指定特定通道时,在conda install xxx后面加上例如-c conda-forge(指定使用conda-forge通道)这样的参数即可。

我们可以通过打开上述默认通道的路径去查看是否存在需要的包,举个例子,打开https://mirrors.aliyun.com/anaconda/cloud/,

依次点击pytorch->win64,我们会发现存在例如pytorch-1.10.0-py3.9_cuda11.3_cudnn8_0.tar.bz2这样的链接名,意即python3.9的pytorch1.10.0-cuda11.3,且这个channel的pytorch1.10.0-gpu支持python3.6,3.7,3.8,3.9,这时候如果用python3.10去拉这个环境是拉不下来的。

  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将conda镜像源更换为国内,你可以按照以下步骤进行操作: 1. 打开Anaconda Prompt。 2. 使用以下命令备份原始的.condarc文件: ``` copy %userprofile%\.condarc %userprofile%\.condarc0 ``` 3. 创建一个新的.condarc文件,可以使用记事本打开并输入以下内容: ``` 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/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ ssl_verify: true ``` 注意,如果你想使用其他国内,可以替上面的链接为其他国内的链接。 4. 保存并将该文件命名为.condarc,并替原始的.condarc文件。 通过以上步骤,你就成功将conda镜像源更换为国内。这样做可以提高下载速度,并且可以在国内更方便地使用conda进行包管理和环境配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [更换Anaconda的下载为国内的办法](https://blog.csdn.net/qq_15719613/article/details/127623065)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值