基于docker的Mobilenet

mac2025-04-05  12

基于docker的Mobilenet_v2 ssdlite caffe环境安装编译

前言安装环境说明Caffe编译填坑记录1、CUDA无法卸载2、CUDA与CUDnn版本不匹配:Check failed: status == CUBLAS_STATUS_SUCCESS (13 vs. 0) CUBLAS_STATUS_EXECUTION_FAILED3..build_release/lib/libcaffe.so: undefined reference to xxxx.bin4、test_im2col_kernel:

前言

Docker环境由于其良好的隔离性,可方便地在同一台机器上进行不同编译环境的安装,同时彼此之间不存在环境变量冲突。弊处在于,在docker之中进行训练,会损失一部分硬件资源。

安装环境说明

CUDA版本:9.0以上,9.0以下会引起其他错误。CUDnn版本:与CUDA版本对应,查询方式见“填坑记录”。Caffe镜像源:docker pull xiaoxinyi/caffe-gpu:8.23(此镜像源大部分环境依赖不用变,比如gcc版本;但CUDA与cudnn需重装,否则会导致错误。)Caffe编译版本:git clone https://github.com/chuanqi305/ssd.git

Caffe编译

可参考如下博文: 1、MobileNetv2-SSDlite训练自己的数据集(一)——配置安装caffe-ssd:(https://blog.csdn.net/qq_43150911/article/details/85097736); 2、lmdb数据集制作方法:(https://blog.csdn.net/JR_Chan/article/details/96316709); 3、MobileNetv2-SSDlite训练自己的数据集(二)——训练MSSD:https://blog.csdn.net/qq_43150911/article/details/85107261。

填坑记录

1、CUDA无法卸载

由于缺少uninstall_cuda_8.0.pl文件,在docker环境中卸载cuda不像实际物理环境中卸载cuda一样(常规方法:找到/usr/local/cuda-8.0/bin/uninstall_cuda_8.0.pl中的.pl文件执行卸载:./uninstall_cuda_8.0.pl),直接删除/usr/local/下的cuda及cuda-8.0文件夹即可。

2、CUDA与CUDnn版本不匹配:Check failed: status == CUBLAS_STATUS_SUCCESS (13 vs. 0) CUBLAS_STATUS_EXECUTION_FAILED

解决办法: 1.查看cuda与cudnn的版本是否匹配: 对照https://developer.nvidia.com/rdp/cudnn-archive显示的对应关系进行比对。如不匹配,需重新安装。 2.如依旧无法解决,安装补丁: 参考链接:http://www.programmersought.com/article/1478102479/,安装patchesPatch 2 (Released Mar 5, 2018):https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=runfilelocal,问题一般到这里可以解决。

3…build_release/lib/libcaffe.so: undefined reference to xxxx.bin

.build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference toboost::filesystem::path::replace_extension(boost::filesystem::path const&)’ .build_release/lib/libcaffe.so: undefined reference to cv::String::allocate(unsigned long)' .build_release/lib/libcaffe.so: undefined reference tocv::String::deallocate()’ .build_release/lib/libcaffe.so: undefined reference to boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator >&, std::vector<int, std::allocator > const&)’ .build_release/lib/libcaffe.so: undefined reference to boost::filesystem::path::stem() const' .build_release/lib/libcaffe.so: undefined reference toboost::filesystem::path::operator/=(boost::filesystem::path const&)’ 此类问题一般是gcc安装版本过高的问题。

4、test_im2col_kernel:

.build_release/cuda/src/caffe/test/test_im2col_kernel.o: In function caffe::Im2colKernelTest_Test2D_Test<double>::TestBody()': tmpxft_0000553d_00000000-5_test_im2col_kernel.compute_75.cudafe1.cpp:(.text._ZN5caffe28Im2colKernelTest_Test2D_TestIdE8TestBodyEv[_ZN5caffe28Im2colKernelTest_Test2D_TestIdE8TestBodyEv]+0x4a3): undefined reference tovoid caffe::im2col_gpu_kernel(int, double const, int, int, int, int, int, int, int, int, int, int, int, int, double)’** 这个问题可能根据不同人的gcc环境而不同,不一定每个人都会遇到。原因是test_im2col_kernel.cpp或test_im2col_kernel.cu文件在调用im2col_gpu_kernel函数进行重载的时候发生了错误,参数个数不一致,需在test_im2col_kernel.cu脚本后面的程序"im2col_gpu_kernel<<<grid_dim, CAFFE_CUDA_NUM_THREADS>>>"中将调用的参数补充完整: im2col_gpu_kernel<<<grid_dim, CAFFE_CUDA_NUM_THREADS>>>( num_kernels, bottom_data + this->blob_bottom_->offset(n), this->height_, this->width_, this->kernel_size_, this->kernel_size_, this->pad_, this->pad_, this->stride_, this->stride_, this->dilation_, this->dilation_, this->height_col_, this->width_col_, top_data + this->blob_top_->offset(n),this->pad_, this->pad_)。

本文引用链接: 1、MobileNetv2-SSDlite训练自己的数据集(一)——配置安装caffe-ssd:(https://blog.csdn.net/qq_43150911/article/details/85097736); 2、lmdb数据集制作方法:(https://blog.csdn.net/JR_Chan/article/details/96316709); 3、MobileNetv2-SSDlite训练自己的数据集(二)——训练MSSD:https://blog.csdn.net/qq_43150911/article/details/85107261。 4、http://www.programmersought.com/article/1478102479/。

最新回复(0)