conda安装pytorch的镜像源问题

caid

分类: 知识小库、经验总结 1769 2

在安装pytorch的时候因为源的问题折腾了非常久,在这记录以下。

问题

报错:

(video_env) D:\profession\code\model\SAAT-master>conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly -c pytorch
Collecting package metadata (current_repodata.json): failed

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "D:\software\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 378, in _load
        raise UnavailableInvalidChannel(self.url_w_repodata_fn, 404)
    conda.exceptions.UnavailableInvalidChannel: The channel is not accessible or is invalid.
      channel name: anaconda/pkgs/free
      channel url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
      error code: 404

    You will need to adjust your conda configuration to proceed.
    Use `conda config --show channels` to view your configuration's current state,
    and use `conda config --show-sources` to view config file locations.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "D:\software\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 371, in _load
        raw_repodata_str = fetch_repodata_remote_request(
      File "D:\software\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 808, in fetch_repodata_remote_request
        raise Response304ContentUnchanged()
    conda.core.subdir_data.Response304ContentUnchanged

    During handling of the above exception, another exception occurred:

我大概就截图这么多吧,大概就这种类型的错误。

网上的办法

设置源:

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://repo.continuum.io/pkgs/free/ 
conda config --add channels https://repo.continuum.io/pkgs/main/ 
conda config --set show_channel_urls yes

最终解决办法

  1. 运行以下命令
conda clean -i
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.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  1. 执行安装命令
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly

注意:在执行的安装pytorch的命令的最后,一定要将 -c pytorch 删除掉
大概就这样。

 

 

  • 7人 Love
  • 0人 Haha
  • 0人 Wow
  • 0人 Sad
  • 0人 Angry
pytorch、项目

作者简介: caid

共 2 条评论关于 “conda安装pytorch的镜像源问题”

Loading...