新安装的ubuntu16.04,安装caffe
Step1:安装Caffe依赖包
$sudo apt-getinstall git
$sudo apt-getinstall libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev
$sudo apt-getinstall libhdf5-serial-dev protobuf-compiler
$sudo apt-getinstall –no-install-recommends libboost-all-dev
$sudo apt-getinstall libatlas-base-dev
$sudo apt-getinstall python-dev
$sudo apt-getinstall libgflags-dev liblmdb-dev libgoogle-glog-dev
Step2:下载Caffe
$git clonehttp://github.com/bvlc/caffe.git
$cd caffe
$mvMakefile.config.example Makefile.config
打开Makefile.config,将CPU_ONLY:=1前的#去掉,即仅使用CPU
Step3:编译
$make all
可能会出现以下错误:
Error1:
./include/caffe/util/hdf5.hpp:6:18 : fata error: hdf5.h No such file or directory
解决方法:
caffe目录下的Makefile.config,第90行修改成下列内容
INCLUDE_DIRS:= $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
修改后再次运行make all
Error2:
LD -o.build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannotfind -lhdf5_hl
/usr/bin/ld: cannotfind -lhdf5
collect2: error: ldreturned 1 exit status
Makefile:566: recipefor target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: ***[.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1
解决方法:
caffe目录下的Makefile(注意不是Makefile.config),第181行修改成下列内容
LIBRARIES+= glog gflags protobuf boost_system boost_filesystem mhdf5_serial_hl hdf5_serial
修改后再次运行make all,编译成功。
Step:4 测试
$make test
$make runtest