Pip 换源
在 user home 目录下新建一个 ~/.pip/pip.config 文件,添加如下配置:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
如果想要临时更换 pip 源,则可以在相应的 pip 命令调用时,在命令的最后加上:
-i https://pypi.tuna.tsinghua.edu.cn/simple
Conda 换源
在 user home 目录下新建一个 .condarc 文件,添加如下配置:
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- default
ssl_verify: true
show_channel_urls: true
Pytorch 包 Conda 下载缓慢的解决办法
Pytorch 下载缓慢的原始是因为在 conda 下载时调用的源较差,Pytorch 的整个安装耗时主要是在 cudatoolkit 和 Pytorch 安装包上了,如果可以在网络环境较好的 conda 源中找到这两个包,就能解决速度慢的问题。
打开 Pytorch 官网,给出的 Linux 版本的安装命令如下:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
我们只需要去掉该命令最后的 -c pytorch,这样在安装的时候就会默认调用用户在系统中设定的默认镜像源:
conda install pytorch torchvision cudatoolkit=10.1
参考资料:
- conda安装Pytorch下载过慢解决办法(11月26日更新ubuntu下pytorch1.3安装方法)_watermelon1123的博客-CSDN博客_conda安装pytorch