可参考:
http://caffe.berkeleyvision.org/install_apt.html(官方)
https://blog.csdn.net/sinat_35188997/article/details/73530434
1、依赖项安装
$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler protobuf-c-compiler protobuf-compiler
2、修改配置文件
$ git clone https://github.com/BVLC/caffe.git
$ cd caffe-master
$ cp Makefile.config.example Makefile.config
# Makefile.config文件中相应位置一定要取消掉注释使其生效,并根据自己的实际情况做相应修改!
5 USE_CUDNN := 1
69 PYTHON_INCLUDE :=
84 PYTHON_LIB :=
92 WITH_PYTHON_LAYER := 1
# Whatever else you find you need goes here.
95 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include
96 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
3、编译
$ mkdir build
$ cd build
$ cmake ..
$ make all -j4
$ make runtest -j4
$ make pycaffe -j4
4、为了能够调用pycaffe 需要加入环境变量
export PYTHONPATH=XXX/caffe-master/python:$PYTHONPATH