0. 本文目的
历经多次安装caffe后,总结一下安装的经验。总结一下使用anaconda下的python来编译caffe的坑。
1. 在anaconda下创建新环境
说明:假设anaconda安装在${HOME}下,即/home/XXX/下。anaconda2或者anaconda3并无影响。建议使用python2来编译,因此在anaconda2/3下创建环境py2Caffe。安装caffe所需要的包.(对于protobuf采用2.5.0或者2.6.1版本,对于protobuf2.5.0采用pip install protobuf==2.5.0安装, protobuf2.6.1采用conda install protobuf==2.6.1). 对于opencv3 采用conda install -c menpo opencv3来安装(opencv2 安装为: conda install -c menpo opencv).
命令如下:
conda create --name py2Caffe python=2.7
2. 修改caffe的Makefile.config文件
1) 下载caffe
命令如下:
git clone https://github.com/BVLC/caffe.git
cp Makefile.config.example Makefile.config
2) 修改Makefile.config文件
修改的部分在下面(GPU + opencv3)
# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
#PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite