之前一直在用pycaffe,很少接触MatCaffe,然而几个论文上的demo需要用到Matcaffe,最近在编译的时候,出现不少错误,记录一下。
环境配置:Ubuntu16.04 + TitanX + Cuda7.5 + Cudnn V4
错误如下:
# make mattest
cd matlab; /usr/local/MATLAB/R2015b/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()'
< M A T L A B (R) >
Copyright - The MathWorks, Inc.
R2015b () -bit (glnxa64)
August ,
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
Invalid MEX-file '/usr/local/caffe/matlab/+caffe/private/caffe_.mexa64': /usr/local/caffe/matlab/+caffe/private/caffe_.mexa64: missing symbol:
中间一堆省略,反正是.mexa64各种missing symbol
Error in caffe.set_mode_cpu (line )
caffe_('set_mode_cpu');
Error in caffe.run_tests (line )
caffe.set_mode_cpu();
经我各种搜索,应该是Matlab的链接库和编译出来的.mexa64有冲突。
exit() #结束之前的错误
在当前的终端环境下输入:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:/usr/local/cuda-/lib64
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.:/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.:/usr/lib/x86_64-linux-gnu/libopencv_core.so.:/usr/lib/x86_64-linux-gnu/libstdc++.so.:/usr/lib/x86_64-linux-gnu/libfreetype.so.
然后再次make mattest即可
但每次编译都需要输入,一个好的办法就是写入到~/.bashrc文件中,然后记得source ~/.bashrc以使得立即生效
参考:http://blog.csdn.net/rt5rte54654/article/details/54742981