1,从github上克隆caffe代码到本地目录
2,安装必要的依赖包
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev
使用openblas时作为数据计算时,必须安装
cp Makefile.config.example Makefile.config
由于hdf5-serial开发包不是安装在系统默认的include和lib目录,需要手工指定hdf5-serial的include目录和lib所在目录,修改配置文件中的这两行,修改后如下:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
修改配置文件中的BLAS := open
3, 编译pycaffe错误
$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directory
##检查Makefile.config文件的70行处
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
## 确认python-numpy是否已安装
$ sudo apt install python-numpy
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-numpy is already the newest version (1:1.11.0-1ubuntu1).
$ ls /usr/lib/python2.7/dist-packages/numpy/core/include
ls: cannot access '/usr/lib/python2.7/dist-packages/numpy/core/include': No such file or directory
## 设置PYTHON_INCLUDE为
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include