conda安装pytorch的镜像源问题

2022-09-13 15:02:15 浏览数 (1)

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

问题

报错:

代码语言:javascript复制
(video_env) D:professioncodemodelSAAT-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:softwareanaconda3libsite-packagescondacoresubdir_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:softwareanaconda3libsite-packagescondacoresubdir_data.py", line 371, in _load
        raw_repodata_str = fetch_repodata_remote_request(
      File "D:softwareanaconda3libsite-packagescondacoresubdir_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:

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

网上的办法

设置源:

代码语言:javascript复制
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. 运行以下命令
代码语言:javascript复制
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. 执行安装命令
代码语言:javascript复制
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly

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

0 人点赞