conda 安装指定版本的指定包

来源:互联网 发布:现在开淘宝店晚吗 编辑:程序博客网 时间:2024/06/05 05:19

因为一些特殊情况,可能会想安装一些特定的包,比如,我自己就在安装tensorflow时不想升级cudnn,而cuda search tensorflow-gpu 有如下结果(只截取了1.2.1版本相关数据,用的清华源):

                             1.2.1           py27cuda7.5cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py27cuda7.5cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py27cuda8.0cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py27cuda8.0cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py35cuda7.5cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py35cuda7.5cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py35cuda8.0cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py35cuda8.0cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py36cuda7.5cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py36cuda7.5cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py36cuda8.0cudnn5.1_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free                              1.2.1           py36cuda8.0cudnn6.0_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 

这时候就发现,光光conda install package=version 不够用了,我只想要py35cuda8.0cudnn5.1_0这个版本的。

解决方案:
从https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 上手动下载对应的包,然后拷贝到conda info中的package cache的pkgs保存目录(不知道为什么,不放到这里会失败),运行:

conda install 下载下来的文件名

可以看到安装成功了,然后看看它需要哪些依赖包(可能有更好的方法,没有深究):

conda info tensorflow-gpu=1.2.1

找到你的包对应的依赖包部分:

tensorflow-gpu 1.2.1 py35cuda8.0cudnn5.1_0------------------------------------------file name   : tensorflow-gpu-1.2.1-py35cuda8.0cudnn5.1_0.tar.bz2name        : tensorflow-gpuversion     : 1.2.1build string: py35cuda8.0cudnn5.1_0build number: 0channel     : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freesize        : 91.1 MBarch        : x86_64date        : 2017-08-04license     : Apache 2.0license_family: Apachemd5         : c7176b7d2ca8ce0c7c6059635272fe04noarch      : Noneplatform    : linuxurl         : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/tensorflow-gpu-1.2.1-py35cuda8.0cudnn5.1_0.tar.bz2dependencies:    backports.weakref ==1.0rc1    bleach ==1.5.0    cudatoolkit 8.0*    cudnn 5.1*    html5lib ==0.9999999    libgcc    markdown >=2.6.8    numpy >=1.11    protobuf >=3.2.0    python 3.5*    six >=1.10.0    werkzeug >=0.11.10

把缺失的依赖包手动安装一下。
如果有更好的办法,欢迎分享~