有时候,多坚持一小下下就成功了,遇到问题就频繁重装系统并不可取!放弃很容易,但坚持真的很酷!
1、安装依赖库也能出问题
命令行输入:
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
出现错误:
Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) /usr/sbin/update-grub: 第 1094 行: read: 读错误: 0: 错误的文件描述符 run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1 dpkg: 处理软件包 linux-image-4.15.0-29-generic (--configure)时出错: 子进程 已安装 post-installation 脚本 返回错误状态 1 在处理时有错误发生: linux-image-4.15.0-29-generic E: Sub-process /usr/bin/dpkg returned an error code (1)
解决办法:
cd /boot/grub
之后:
sudo update-grub
再安装依赖库就可以了。
2、Caffe倒是很容易配置好,编译matcaffe的时候,出现问题:
make mattest时报错:
Invalid MEX-file 'caffe/matlab/+caffe/private/caffe_.mexa64': caffe/matlab/+caffe/private/caffe_.mexa64: undefined symbol: _ZN2cv8imencodeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArrayERSt6vectorIhSaIhEERKSB_IiSaIiEE。 Error in caffe.set_mode_cpu (line 5) caffe_('set_mode_cpu'); Error in caffe.run_tests (line 6) caffe.set_mode_cpu();
有些说法是要执行如下命令:
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
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
但是再次运行make mattest时会有新错误:
malloc: unknown:0: assertion botched free: called with unallocated block argument last command: (null) Aborting...find: ‘bash’ terminated by signal 6
虽然最后还是能运行成功,但发现在运行bash指令时无法成功执行,纠结了好久发现是这里没有彻底解决问题,解决方法是:
将 libopencv_imgproc.so.2.4, libopencv_core.so.2.4, libopencv_highgui.so.2.4三个文件拷贝到/usr/local/MATLAB/R2016b/bin/glnxa64/中
sudo mv /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_imgproc.so.2.4.old sudo cp /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/ sudo mv /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_core.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_core.so.2.4.old sudo cp /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/ sudo mv /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_highgui.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/libopencv_highgui.so.2.4.old sudo cp /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4 /usr/local/MATLAB/R2016a/bin/glnxa64/
注:上面是我的matlab、opencv版本以及路径。
再执行:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
bash指令没有问题了,搞定。
3、caffe编译时的NVCC warning问题
在编译caffe的Mkefile.config时遇到报错
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
原因是,Makefile中采用了CUDA的compute capability 2.0和2.1,这是两种计算能力。安装的CUDA版本是8.0,但 从CUDA 8.0开始compute capability 2.0和2.1被弃用了,所以可以将-gencode arch=compute_20,code=sm_20 和-gencode arch=compute_20,code=sm_21这两行删除即可。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Caffe+Matlab’hole - Python技术站