DeepLab V2安装配置
来源:互联网 发布:java开发工程师视频 编辑:程序博客网 时间:2024/06/04 17:49
2016年Semantic Segmentation方向比较出色的一篇文章,DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs
https://arxiv.org/abs/1606.00915
作者提供了开源的代码,shell版本:https://bitbucket.org/aquariusjay/deeplab-public-ver2
和python版本:https://github.com/TheLegendAli/DeepLab-Context2
以及相关Model下载:
http://liangchiehchen.com/projects/DeepLab_Models.html
作者所使用的Caffe版本比较陈旧,导致会出现很多和最新环境不兼容的情况。我使用的环境是Ubuntu 16.04, CUDA 8.0, cuDNN 5.1, Python 2.7.12,以下就以这个配置写个简单流程说明。
1.安装
1.1 安装Matio
下载matio(https://sourceforge.net/projects/matio/files/matio/1.5.2/)
$ tar zxf matio-1.5.2.tar.gz$ cd matio-1.5.2$ ./configure$ make$ make check$ make install$ sudo ldconfig
1.2 安装wget
执行脚本时如果提示 ImportError: No module named wget,说明还需要安装wget
sudo pip install wget
2.编译
和BVLC版本一样,对DeepLab版本的caffe进行编译
make -j8make test -j8make pycaffemake pytest
2.1 CUDA8.0环境下atomicAdd错误
编译时会出现如下错误提示:
./include/caffe/common.cuh(9): error: function "atomicAdd(double *, double)" has already been defined
原因是CUDA 8.0 提供了对atomicAdd函数的定义,但atomicAdd在之前的CUDA toolkit中并未出现,因此一些程序自定义了atomicAdd函数。
解决方法:打开./include/caffe/common.cuh文件,在atomicAdd前添加宏判断即可。
如下:
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600 #else static __inline__ __device__ double atomicAdd(double* address, double val) { ... } #endif
再次编译程序即可。
2.2 cuDNN v5环境会出现类似下面的接口错误
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’ pad_h, pad_w, stride_h, stride_w));
这是由于所使用的cuDNN版本不一致的导致的,作者配置环境是cuDNN 4.0,但是5.0版本后的cuDNN接口有所变化。
解决方法 :将以下几个文件用最新BVLC版本的caffe对应文件替换并重新编译
./include/caffe/util/cudnn.hpp./include/caffe/layers/cudnn_conv_layer.hpp./include/caffe/layers/cudnn_relu_layer.hpp./include/caffe/layers/cudnn_sigmoid_layer.hpp./include/caffe/layers/cudnn_tanh_layer.hpp./src/caffe/layers/cudnn_conv_layer.cpp./src/caffe/layers/cudnn_conv_layer.cu./src/caffe/layers/cudnn_relu_layer.cpp./src/caffe/layers/cudnn_relu_layer.cu./src/caffe/layers/cudnn_sigmoid_layer.cpp./src/caffe/layers/cudnn_sigmoid_layer.cu./src/caffe/layers/cudnn_tanh_layer.cpp./src/caffe/layers/cudnn_tanh_layer.cu
2.3 如果使用cmake编译时可能会遇到以下错误
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_VarFree'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_VarReadDataLinear'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_Open'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_VarCreate'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_CreateVer'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_VarWrite'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_VarReadInfo'../lib/libcaffe.so.1.0.0-rc3: undefined reference to `Mat_Close'
解决方法:
下载FindMATIO.cmake.zip文件,解压缩后拷贝到./cmake/Modules目录中。
文件下载路径:https://github.com/TheLegendAli/DeepLab-Context/files/453735/FindMATIO.cmake.zip
并添加以下代码至./cmake/Dependencies.cmake文件中
find_package(MATIO REQUIRED)include_directories(${MATIO_INCLUDE_DIR})list(APPEND Caffe_LINKER_LIBS ${MATIO_LIBRARIES})
3.运行脚本
python run.py
3.1 v1和v2版本兼容性问题
Error parsing text-format caffe.NetParameter: 316:9: Message type "caffe.ConvolutionParameter" has no field named "hole".
v1版本中将Atrous Convolution的参数称为”hole”,而v2为了和BVLC版本一致而改称为”dilation”。因此将train.prototxt中的hole全部替换为dilation即可。
3.2 继续改错
为了增加对v1版本prototxt的兼容性,还需要对源代码进行多项改动,需要增加对ImageSegDataLayer, InterpLayer, SegAccuracyLayer, MatWriteLayer这几层对prototxt文件信息的支持。首先在./src/caffe/proto/caffe.proto文件中添加唯一ID
message V1LayerParameter { enum LayerType { IMAGE_SEG_DATA = 40; INTERP = 41; SEG_ACCURACY = 42; MAT_READ = 44; MAT_WRITE = 43; } optional InterpParameter interp_param = 43; optional SegAccuracyParameter seg_accuracy_param = 44; optional MatReadParameter mat_read_param = 51; optional MatWriteParameter mat_write_param = 45;}
./src/caffe/util/upgrade_proto.cpp文件的UpgradeV1LayerType(const V1LayerParameter_LayerType type)函数中添加
const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type) { switch (type) {case V1LayerParameter_LayerType_IMAGE_SEG_DATA: return "ImageSegData";case V1LayerParameter_LayerType_INTERP: return "Interp";case V1LayerParameter_LayerType_SEG_ACCURACY: return "SegAccuracy";case V1LayerParameter_LayerType_MAT_WRITE: return "MatWrite";}
还需要补充对InterpLayer参数interp_param的支持,
bool UpgradeV1LayerParameter(const V1LayerParameter& v1_layer_param, LayerParameter* layer_param) {if (v1_layer_param.has_interp_param()) { layer_param->mutable_interp_param()->CopyFrom( v1_layer_param.interp_param()); }}
- DeepLab V2安装配置
- DeepLab V2 配置bug
- DeepLab v2 配置
- deeplab-v2 安装问题总结
- DeepLab v2安装问题解决-------安装笔记
- <caffe安装系列>deeplab-v2问题总结
- 图像分割 DeepLab v2
- [Paper Reading] DeepLab v1 & v2
- Deeplab V1 和 V2讲解
- 基于deeplab v2的语义分割
- 论文阅读:《DeepLab-v2: Semantic Image Segmentation 》
- Deeplab-v2 编译过程中的问题
- deepLab
- 语义分割DeepLab v2--DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolut
- 基于deeplab v2的语义分割参考博文
- Deeplab v2 调试全过程(Ubuntu 16.04+cuda8.0)
- jspwiki v2.1.86基本安装和配置
- 图像语义分割:从头开始训练deeplab v2系列之四【nyu v2数据集】
- 第1章 初始Docker
- STM8S_004_UART基本收发数据
- C/C++广度优先搜索模拟迷宫求解问题
- 欢迎使用CSDN-markdown编辑器
- Windows 下安装 TensorFlow
- DeepLab V2安装配置
- UVA
- 用栈实现的计算器
- python(3)基本句型
- 浅析利用高斯核函数进行半监督分类
- autoproxy 匹配规则
- 谈一谈如何远程访问MySQL(腾讯云,云主机)
- 【PHP】验证码Demo
- Bitmap.Config RGB_565 ARGB_8888