Caffe配置过程中的一些问题
参考链接:
https://groups.google.com/forum/#!topic/caffe-users/x8Y26vf-or8
http://blog.csdn.net/striker_v/article/details/52890747
http://www.echojb.com/cuda/2017/05/05/375103.html
http://www.caffecn.cn/?/question/1113
https://blog.csdn.net/dym755833564/article/details/77965966
GCC版本太新
在make过程中可能 string.h ‘memcy’ was not declared in this scope的错误,这是因为ubuntu中gcc编译器版本太新,解决方法是打开Makefile文件,找到下面这行代码(大概在409行左右):
1 | NVCCFLAGS += -ccbin=(CXX)−Xcompiler−fPIC(COMMON_FLAGS) |
将其改为:
1 | NVCCFLAGS += -D_FORCE_INLINES -ccbin=(CXX)−Xcompiler−fPIC(COMMON_FLAGS) |
make matcaffe时报错
1 | /home/zkk/caffe/matlab/+caffe/private/caffe_.cpp: In function ‘void delete_solver(int, mxArray**, int, const mxArray**)’: |
修改Makefile里面的CXXFLAGS,添加CXXFLAGS += -std=c++11.然后重新编译就可以了,即:
1 | CXXFLAGS += -MMD -MP |
注意: 是添加不是修改
make mattest时报错:
1 | Invalid MEX-file 'caffe/matlab/+caffe/private/caffe_.mexa64': |
有些说法是要执行如下命令:
1 | export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libfreetype.so.6 |
但是再次运行make mattest时会有新错误:
1 | malloc: unknown:0: assertion botched |
虽然最后还是能运行成功,但发现在运行bash指令时无法成功执行,纠结了好久发现是这里没有彻底解决问题,解决方法是:
将 libopencv_imgproc.so.2.4, libopencv_core.so.2.4, libopencv_highgui.so.2.4三个文件拷贝到/usr/local/MATLAB/R2016b/bin/glnxa64/中
1 | $ sudo mv /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2016b/bin/glnxa64/libopencv_imgproc.so.2.4.old |
再执行
1 | export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 |
问题就解决啦,bash指令也没有问题啦
关于opencv
make all时报错,错误信息:
1 | ... |
首先,已经配置过了opencv,可以这样查询安装版本:
1 | $ pkg-config --modversion opencv |
所以出现上面的错误,应该是opencv_imgcodecs链接的问题,比较有效的解决方案是,把opencv需要的lib添加到Makefile文件中,找到LIBRARIES(在PYTHON_LIBRARIES := boost_python python2.7 前一行),并进行修改,向该句末尾添加:
1 | opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs |
我的Makefile文件修改后为:
1 | LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5 opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs |