解决办法是依据出现错误的顺序而给出的,为了方便,可以直接先执行所有解决办法后再安装caffe。
1. ./include/caffe/common.hpp:5:27: fatal error: gflags/gflags.h: No such file or directory
解决办法:sudo apt-get install libgflags-dev
2. ./include/caffe/util/mkl_alternate.hpp:14:19: fatal error: cblas.h: No such file or directory
解决办法:sudo apt-get install libblas-dev
3. ./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
解决办法:在Makefile.config找到以下行并添加蓝色部分
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
4. ./include/caffe/util/db_lmdb.hpp:8:18: fatal error: lmdb.h: No such file or directory
解决办法:sudo apt install liblmdb-dev
5. /usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
解决办法:sudo apt install libatlas-base-dev
6. caffe /usr/bin/ld: 找不到 -lhdf5_hl
打开Makefile,将第181行的:
laiyuanyu http://blog.csdn.net/autocyz/article/details/51783857
//重要的一项
将# Whatever else you find you need goes here.下面的
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/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 /usr/lib/x86_64-linux-gnu/hdf5/serial
//这是因为ubuntu16.04的文件包含位置发生了变化,尤其是需要用到的hdf5的位置,所以需要更改这一路径
cd /usr/lib/x86_64-linux-gnu
\\然后根据情况执行下面两句:
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
7.
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
#include // NOLINT(build/include_alpha)
遇到此类问题基本是caffe找不到python,因此在make py之前反复确认下anaconda或python所在目录是否存在。
因此需要修改。