问题

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

'https://repo.anaconda.com/pkgs/main/win-64'
  • 默认镜像访问速度过慢,会导致超时

解决方法

  • 进入目标虚拟环境,如果没有,就新建一个

    conda crate -n pytorch python=3.7
    
  • 进入目标虚拟环境

    conda activate pytorch
    
  • 更换镜像源为国内源,删除默认镜像源

    • 配置文件:

      • 文件位置

        • Windows:%HOMEPATH%/.condarc
        • Linux:~/.condarc
      • 用户目录下不存在该文件,可在Anaconda Prompt中执行以下命令创建该文件

        conda config
        
    • 添加国内源

      conda config --remove-key channels
          
      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
      
  • 为该虚拟环境安装pytorch

    conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch