引言:为什么研究这个
起因是安装paddlepaddle包后,发现不能用GPU,因为没有对应的cuda和cudnn,按照官网的
conda install paddlepaddle-gpu==2.3.1 cudatoolkit=11.2 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge,报错找不到对应的包。
但是很明显这行指令是希望在conda-forge频道下载cudatoolkit。
一方面它报错了,令一方面conda-forge服务器在国外,下载速度缓慢。因此直接在国内找镜像。
解决方案
我们都知道,pypi的镜像有很多,也易用。但是conda-forge似乎索引方式比较特别,直接指定conda-forge的镜像,装包并不一定能成功。接下来是利用国内镜像快速装conda-foge包的解决方案。这里以阿里云镜像为例
第一步:找到各大国内镜像conda-forge的地址
首先找到阿里云conda-forge镜像对应的目录
mirrors.aliyun.com/anaconda/cl…
第二步:下载包的索引文件
我们希望直接找到我们需要装的包,但是点开linux-64页面打开非常缓慢,可能根本打不开,因为内部文件太多,太大了。
可以通过自己补全链接,下载索引文件
mirrors.aliyun.com/anaconda/cl…/repodata.json
第三步:安装文件地址获取和下载
下载得到索引文件repodata.json之后,搜索找到自己需要的包
以cudnn为例,在repodata.json中搜索,补全下载链接
"cudnn-8.0.5.39-h01f27c4_1.tar.bz2": {
"build": "h01f27c4_1",
"build_number": 1,
"depends": [
"__glibc >=2.17,<3.0.a0",
"cudatoolkit 10.2|10.2.*",
"libgcc-ng >=3.0",
"libstdcxx-ng >=3.4"
],
"license": "cuDNN Software License Agreement",
"md5": "606015328c0881ec923a059b82de1a79",
"name": "cudnn",
"sha256": "114d33e586c6d96bee6c143a640638cdff28e877b249a07b33b9a4433aa441d4",
"size": 342894867,
"subdir": "linux-64",
"timestamp": 1609280936178,
"version": "8.0.5.39"
}
mirrors.aliyun.com/anaconda/cl…
就可以获得本地的安装文件的下载链接,下载!
第四步:本地安装
进入本地安装文件目录,运行
conda install cudnn-8.0.5.39-h01f27c4_1.tar.bz2
即可完成安装
但是 cudatoolkit-11.2.2-hbe64b41_10.tar.bz2 下载好慢,还没有conda-forge快
后记
按道理下面这么配置就可以,但是对于不确定是否有的包,通过上面的方法会更加直观
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.aliyun.com/anaconda/pkgs/main
- http://mirrors.aliyun.com/anaconda/pkgs/r
- http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.aliyun.com/anaconda/cloud
msys2: http://mirrors.aliyun.com/anaconda/cloud
bioconda: http://mirrors.aliyun.com/anaconda/cloud
menpo: http://mirrors.aliyun.com/anaconda/cloud
pytorch: http://mirrors.aliyun.com/anaconda/cloud
simpleitk: http://mirrors.aliyun.com/anaconda/cloud