【教程】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去拉这个环境是拉不下来的。

相关推荐

  1. 教程Conda更换镜像安装pytorch

    2023-12-13 05:34:02       65 阅读
  2. npm和pnpm安装更换镜像

    2023-12-13 05:34:02       38 阅读
  3. conda 安装教程分享

    2023-12-13 05:34:02       61 阅读
  4. ubuntu下conda如何设置镜像(清华镜像

    2023-12-13 05:34:02       54 阅读
  5. conda和pip配置国内镜像

    2023-12-13 05:34:02       62 阅读
  6. conda镜像,Jupyter内核配置

    2023-12-13 05:34:02       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-13 05:34:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-13 05:34:02       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-13 05:34:02       82 阅读
  4. Python语言-面向对象

    2023-12-13 05:34:02       91 阅读

热门阅读

  1. PHP基础(4)

    2023-12-13 05:34:02       65 阅读
  2. go的结构体作为返回值

    2023-12-13 05:34:02       59 阅读
  3. AtCoder ABC175

    2023-12-13 05:34:02       56 阅读
  4. 【数据结构和算法】种花问题

    2023-12-13 05:34:02       56 阅读
  5. 深入浅出接口测试原理及步骤

    2023-12-13 05:34:02       54 阅读
  6. linux的免密登录

    2023-12-13 05:34:02       63 阅读
  7. MTK Android P Sensor架构(二)

    2023-12-13 05:34:02       65 阅读
  8. *上位机的定义

    2023-12-13 05:34:02       64 阅读
  9. 数据结构和算法专题---5、调度算法与应用

    2023-12-13 05:34:02       50 阅读