win10下配caffe(仅cpu, python接口) - 成功

  • 先提醒:如果不是装的python3.5或2.7的anaconda,那么建议以前装过的python、anaconda全卸载。最好要有anaconda而不是直接安python,这样后面会省很多事。就是这个原因,第一次配没成功:win10下配caffe(仅cpu, python接口) - 失败
  • 先明确需求,我是要在64位win10下、仅cpu、使用python接口

1 需要提前安装和下载的

先在Github: Caffe-Windows看一下环境要求:

在明确需求的情况下,有以下几个需安装:

  • Visual Studio 2013 / 2015
  • CMake 3.4 or higher
  • Anaconda Python 2.7 or 3.5 x64
  • 另外,后面会用到Git

下面进行下载安装:

  1. Visual Studio 2013 / 2015
    这个我就跳过吧...本人的是VS2015
  2. CMake 3.4 or higher
    我选择了cmake 3.10,参考了:拜小白一步一步教你CMake3.8.2安装教程
    官网下载了:
    记得点添加环境变量:
    可查看版本:
  3. Anaconda Python 2.7 or 3.5 x64
    安装过程中会遇到问题,所以单独写了一个,请参考:Anaconda安装中遇到的问题
  4. (后面会用到的)Git
    参考了:.4 起步 - 安装 Git
    官网的Download中下载了2.17.0并安装

2 Configuring and Building Caffe 配置和构建Caffe

按照Github: Caffe-Windows的:

即:

C:\Projects> git clone https://github.com/BVLC/caffe.git
C:\Projects> cd caffe
C:\Projects\caffe> git checkout windows
:: Edit any of the options inside build_win.cmd to suit your needs
C:\Projects\caffe> scripts\build_win.cmd

以上都是指在命令提示符(即win+R,cmd回车)中的命令,下面一行一行来

  1. 前3行命令
    先更换到自己想放caffe的路径,然后执行:
    (line 1)C:\Projects> git clone https://github.com/BVLC/caffe.git
    会在当前路径下形成“caffe”文件夹
    然后
    (line 2)C:\Projects> cd caffe

    (line 3)C:\Projects\caffe> git checkout windows
    到这都很简单,不会有什么问题。
  2. 第4行命令
    在执行前,打开scripts\build_win.cmd,根据自己的情况做更改,主要改下面几项,怎么改说明写得很清楚:
    然后执行
    (line 4)C:\Projects\caffe> scripts\build_win.cmd
    然后会跑几分钟,并出现一些警告,不用管

3 Using the Python interface 使用Python接口

按照Github: Caffe-Windows的:

即:

conda config --add channels conda-forge
conda config --add channels willyd
conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
把caffe目录下的python\caffe整个文件夹,复制到anaconda的安装路径下Lib\site-packages中

其中:
(line 1)conda config --add channels conda-forge

(line 2)conda config --add channels willyd
我记得都不会有什么问题。
但到了
(line 3)conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
执行以后下载太慢了,一看共300多兆,不知道下到猴年马月。需要下载的如下图:

于是我果断想了个办法手动下载。其实可以挑比较大的手动下载,其他的执行一遍line3自动下载。手动下载方式如下:

  1. 进入anaconda安装目录下的pkgs文件夹,这些包下载后都在这
  2. 用下载工具(我用的是IDM,见IDM 下载及设置和使用),复制包的url(怎样确定一个包的url,会在下面说),下载并拷贝到文件夹
  3. 把每个包的url复制到同路径下的url.txt中

都下载好后,可以再执行一遍line3,会显示这种:

然后做最后一步:
(line 4)把caffe目录下的python\caffe整个文件夹,复制到anaconda的安装路径下Lib\site-packages中
在python中import caffe出现换行不报错,就成功了:

  • 怎样确定一个包的url
    由于包的url都在url.txt中,所以可以根据显示缺少的包名,总结和猜测url。我的urls.txt复制到下面(只复制后来添加的),可以从里面找,找到根据自己电脑显示的改一下包的数字,就可以了。找不到的,如果执行命令也无法下载,就根据已有信息总结和猜测吧
https://conda.anaconda.org/conda-forge/win-64/numexpr-2.6.5-py35_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/six-1.11.0-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/imageio-2.3.0-py35_0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/dask-core-0.17.5-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/astropy-2.0.6-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/cmake-3.11.1-0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/openblas-0.2.20-vc14_7.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/scikit-image-0.13.1-py35_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/matplotlib-2.2.2-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/pyyaml-3.12-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/pandas-0.23.0-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/vs2008_runtime-9.0.30729.6161-0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/bottleneck-1.2.1-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/llvmlite-0.23.0-py35_1.tar.bz2
https://repo.continuum.io/pkgs/main/win-64/scikit-learn-0.19.1-py35h2037775_0.tar.bz2
https://repo.continuum.io/pkgs/main/win-64/numba-0.38.0-py35h830ac7b_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/kiwisolver-1.0.1-py35_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/openmp-5.0.0-vc14_1.tar.bz2
https://repo.anaconda.com/pkgs/main/win-64/mkl-2018.0.2-1.tar.bz2
https://repo.continuum.io/pkgs/main/win-64/icc_rt-2017.0.4-h97af966_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/graphviz-2.38.0-7.tar.bz2
https://conda.anaconda.org/willyd/win-64/protobuf-3.1.0-py35_vc14_1.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/statsmodels-0.9.0-py35_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/pydotplus-2.0.2-py35_0.tar.bz2
https://repo.continuum.io/pkgs/main/win-64/scipy-1.1.0-py35h672f292_0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/libflang-5.0.0-vc14_20180208.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/numpy-1.14.3-py35_blas_openblas_200.tar.bz2
https://conda.anaconda.org/willyd/win-64/ninja-1.7.1-0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/llvm-meta-5.0.0-0.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/yaml-0.1.7-vc14_0.tar.bz2
https://repo.continuum.io/pkgs/main/win-64/intel-openmp-2018.0.0-8.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/blas-1.1-openblas.tar.bz2
https://conda.anaconda.org/conda-forge/win-64/pywavelets-0.5.2-py35_1.tar.bz2

你可能感兴趣的:(win10下配caffe(仅cpu, python接口) - 成功)