简单记录一下服务器端安装openpose遇到的问题与解决办法
一、安装
1.若无caffe,首先编译生成caffe
$ cd 3rdparty/caffe
$ cp Makefile.config.Ubuntu14_cuda7.example Makefile.config #Ubuntu14.04 + Cuda7.5
$ make all -j8 #8核
$ make distribute -j8 #制作caffe的发布版本
遇到错误:
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit statusmake: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1make: ***
Waiting for unfinished jobs....
原因:服务器装的是opencv3.0,opencv3.0把imread相关函数放到imgcodecs.lib中了,而非原来的imgproc.lib
解决办法:
打开caffe目录下的
Makefile
(注意不是Makefile.config) ,在如下位置加入imgcodecs等库
LIBRARIES += glog gflags protobuf leveldb snappy lmdb boost_system hdf5_hl hdf5 m
opencv_core opencv_imgproc opencv_imgcodecs
//在后面加入opencv_core opencv_imgproc opencv_imgcodecs
注意事项:
重新生成时,先清除再编译
$ make clean
$ make all -j8 && make diatribute -j8
参考:https://blog.csdn.net/fansetcool/article/details/51569374
2.下载训练好的caffe模型
$ cd models
$ ./getModels.sh
3.生成openpose
$ mkdir build
$ cd build
$ cmake ..
$ make all -j8
二、问题
1.OpenCV错误
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
原因:OpenCV路径不是cmake的默认路径,编译时找不到OpenCV
$ export OpenCV_DIR=/usr/local/opencv-3.0.0
2.DOWNLOAD HASH mismatch
CMake Error at cmake/Utils.cmake:8 (file):
file DOWNLOAD HASH mismatch
for file: [/home/wuyan-ding/data/Projects/openpose/models/pose/coco/pose_iter_440000.caffemodel]
expected hash: [5156d31f670511fce9b4e28b403f2939]
actual hash: [ef1ffc880e3f690af76e05477654755d]
解决方法:使用SSL重新cmake编译
3.CUDNN_STATUS错误
F0704 09:30:35.277140 13587 cudnn_conv_layer.cpp:53] Check failed: status == CUDNN_STATUS_SUCCESS (4 vs. 0) CUDNN_STATUS_INTERNAL_ERROR
*** Check failure stack trace: ***
原因:caffe编译时环境变量设置有问题,重新设置
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3 #取消本行注释
#本服务器用的GPU算力3.5,将高于35的均注释掉
CUDA_ARCH := -gencode arch=compute_20,code=sm_20\
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35
#增加对hdf5的索引
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
4.CaffeModel参数错误
F0704 14:27:12.379647 5860 upgrade_proto.cpp:97] Check failed: ReadProtoFromBinaryFile(param_file, param) Failed to parse NetParameter file: models/pose/body_25/pose_iter_584000.caffemodel
*** Check failure stack trace: ***
出现上述错误,不是你项目编译有问题,也不是caffe编译有问题,仅仅是caffe模型没有下载完全!!!
使用 ./getModels.sh 命令下载文件奇慢,整个Mosels文件夹700多M,下载速度是 kb/s级别的,所以我将下载好的模型传到百度云,文件夹中的 .caffemodel 文件就是待下载模型,可以对应的拷到自己的项目文件夹中,地址是:
链接:
https://pan.baidu.com/s/1h_d0dw8OXJ2Ys4-djgW7BQ 密码:725r