虚拟机
- ubuntu 16.14
- open CV 3.3.0
- caffe CPU
- openpose
https://github.com/CMU-Perceptual-Computing-Lab/openpose
不需要装显卡驱动和cuda cudnn
安装 Caffe
-
安装各种依赖包
sudo apt-get install -y --no-install-recommends libboost-all-dev sudo apt-get install -y --no-install-recommends libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler libopenblas-dev libatlas-base-dev
-
下载caffe
git clone https://github.com/BVLC/caffe cd caffe export CAFFE_HOME=${PWD}
-
安装python依赖
sudo apt-get install -y --no-install-recommends python-pip export LC_ALL=C sudo pip install scikit-image protobuf cd ${CAFFE_HOME}/python for req in $(cat requirements.txt); do sudo pip install $req; done
-
修改caffe的Makefile文件
cd CAFFE gedit Makefile.config
几个需要调整的内容如下,其他地方按需调整
-
使用CPU还是GPU
# CPU-only switch (uncomment to build without GPU support). CPU_ONLY := 1
-
设置OpenCV版本
# Uncomment if you're using OpenCV 3 OPENCV_VERSION := 3
-
设置anaconda目录
# ANACONDA_HOME := $(HOME)/anaconda2 # PYTHON_LIB := $(ANACONDA_HOME)/lib
-
-
构建
make all
遇到错误
-
编译失败,缺少openlabs
错误
In file included from ./include/caffe/util/math_functions.hpp:11:0, from src/caffe/data_transformer.cpp:10: ./include/caffe/util/mkl_alternate.hpp:14:19: fatal error: cblas.h: No such file or directory compilation terminated. Makefile:581: recipe for target '.build_release/src/caffe/data_transformer.o' failed make: *** [.build_release/src/caffe/data_transformer.o] Error 1
解决
sudo apt-get install libopenblas-dev
-
编译失败,找不到文件
hdf5.h
错误
src/caffe/layers/hdf5_data_layer.cpp:13:18: fatal error: hdf5.h: No such file or directory compilation terminated. Makefile:581: recipe for target '.build_release/src/caffe/layers/hdf5_data_layer.o' failed make: *** [.build_release/src/caffe/layers/hdf5_data_layer.o] Error 1
解决
查找 hdf5.h 文件的位置,例如在 /usr/include/hdf5/serial/hdf5.h 修改Makefile.config,修改属性 INCLUDE_PATH,添加属性值 /usr/include/hdf5/serial
-
链接失败,找不到文件
hdf5_hl
hdf5
cblas
atlas
错误
LD -o .build_release/lib/libcaffe.so.1.0.0 /usr/bin/ld: cannot find -lhdf5_hl /usr/bin/ld: cannot find -lhdf5 collect2: error: ld returned 1 exit status Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
解决
-
locate libhdf5 的路径 并加入 LIBEARY_DIRS 空格增加路径
-
链接失败,找不到文件
lcblas
latlas
错误
LD -o .build_release/lib/libcaffe.so.1.0.0 /usr/bin/ld: cannot find -