最近要解读一个Python程序,需要里面用到了caffe,试着import一下:

好吧,没安装,那我就按常规方法pip安装试试

额,也许是我的pip版本太低了,先升级它再安装试试
先
python -m pip install --upgrade pip
升级,然后……

好吧,通过pip安装行不通,那就百度找找方法,经过几番验证,最后
找到了这位大佬的博客Caffe 在 win10 环境下配置,这位大佬在 windows 环境下的 caffe 编译,实现 win10 + caffe + vs2013 + anaconda2.7 + cuda8.0 + cuDNN_v5,但是本屌丝并没有GPU加速,只好对其安装过程进行了一些修改。
材料准备
在安装caffe之前必须安装这么些东西
numpy,scipy,matplotlib,scikit-image
编译平台是:
Microsoft Visual Studio Ultimate 2013(简体中文旗舰版)
Python版本是2.7
1.下载caffe
点击 Clone or download-> Download ZIP,解压缩,把caffe-master/caffe-master/windows/下的CommonSettings.props.example
文件改名为CommonSettings.props
2.修改CommonSettings.props
用VS2013打开caffe-master/caffe-master/windows/下的Caffe.sln
文件,修改CommonSettings.props
文件内容:

由于只使用CPU
CpuOnlyBuild修改为true
UseCuDNN修改为false
PythonSupport修改为true
PythonDir修改为Python安装路径


3.编译
编译顺序为libcaffe -> caffe ->pycaffe
右击libcaffe,点击“属性”

上方的配置选为活动(Release),平台选为活动(x64),点击 C/C++,“将警告视为错误”设为 “否”

然后选中libcaffe,右击选择“生成”,等待编译直至编译成功。这样libcaffe就编译好了。

同样的方法去编译caffe 和 pycaffe,最后把caffe-master\Build\x64\Release\pycaffe
下的caffe文件夹复制到Python27\Lib\site-packages
文件夹下。
然后测试一下:

ok,安装成功
网友评论