最近在研究用深度学习预测图像深度信息的方法,一开始用的是2017年CVPR上Godard大神的monodepth,代码在这里。这篇文章介绍了利用双目的consistency训练网络以对单张图像进行深度估计,思路还是蛮有新意的。某天在必应上无意中发现了商汤(sensetime)的Yue Luo同学发表在2018年CVPR上的一篇文章Single View Stereo Matching,代码开源了,因此fork一下clone下来跑一跑,没想到按照readme跑第一步installation就遇到了几个问题,在网上都没有找到问题的解决办法,于是自己花了点时间解决了这些问题,特此记录,以示其他同学。

1.makefile.config缺失问题

原作者给了一个Makefile.config.example,各位同学如果要install的话记得把.example去掉,我们需要的是Makefile.config。

里面的参数是否要取消注释讲的很清楚,我使用了cudnn,因此取消注释USE_CUDNN := 1。我的opencv版本是3.2.0,因此取消注释OPENCV_VERSION := 3。对于CUDA_ARCH,如果你的CUDA版本比较高,建议你删掉compute_20和compute_21这两行。然后就是一些引用库的路径,后面会说到。

2.缺少hdf5.h问题

首先安装hdf5,你需要在官网下载hdf5,然后解压编译安装

$ cd hdf5-1.10.3
$ mkdir build
$ cd build
$ cmake ..
$ sudo make
$ sudo make install

如果遇到问题,我的另一篇文章里介绍了如何解决hdf5的安装问题。

安装好了hdf5之后,需要在Makefile.config里加入链接,以保证可以调用hdf5的库。对于我来说,我需要在这里加

HDF5_DIRS :=/home/yao/Environment/hdf5-1.10.3/hdf5
OpenCV_DIR :=/home/yao/Environment/opencv-3.2.0/build

我顺便加了一个OpenCV的路径,以防需要。同学们把前面的路径改成自己的路径即可。然后将下面的两行

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

改为

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include $(HDF5_DIRS)/include $(OpenCV_DIR)/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib $(HDF5_DIRS)/lib $(OpenCV_DIR)/lib

3.cudnn版本的问题

make的时候发现了如下的问题

In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from src/caffe/syncedmem.cpp:1:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::setConvolutionDesc(cudnnConvolutionStruct**, cudnnTensorDescriptor_t, cudnnFilterDescriptor_t, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:112:3: error: too few arguments to function ‘cudnnStatus_t cudnnSetConvolution2dDescriptor(cudnnConvolutionDescriptor_t, int, int, int, int, int, int, cudnnConvolutionMode_t, cudnnDataType_t)’
   CUDNN_CHECK(cudnnSetConvolution2dDescriptor(*conv,
   ^
In file included from ./include/caffe/util/cudnn.hpp:5:0,
                 from ./include/caffe/util/device_alternate.hpp:40,
                 from ./include/caffe/common.hpp:19,
                 from src/caffe/syncedmem.cpp:1:
/usr/local/cuda/include/cudnn.h:537:27: note: declared here
 cudnnStatus_t CUDNNWINAPI cudnnSetConvolution2dDescriptor( cudnnConvolutionDescriptor_t convDesc,
                           ^
Makefile:579: recipe for target '.build_release/src/caffe/syncedmem.o' failed
make: *** [.build_release/src/caffe/syncedmem.o] Error 1
make: *** Waiting for unfinished jobs....

在网上看了一下,是这份代码提供的cudnn版本太老,从别的caffe里比如caffe/include/caffe/util复制cudnn.hpp到SVS/caffe/include/caffe/util/目录下,即可解决。

4.src/caffe/util/util_img.cpp中caffe::BlobToGrayImage函数的问题

接下来的几步的问题都比较隐蔽,要在命令行的编译结果里仔细找才能看到。这一步的问题我在github的issue里也看到了,好几个人都在讨论怎么解决,大家没什么办法,作者似乎也不太清楚怎么回事,我自己研究了一下,解决了这个问题,还是比较有成就感的。

这一步的主要问题如下

src/caffe/util/util_img.cpp: At global scope:
src/caffe/util/util_img.cpp:709:33: error: redeclaration of ‘template<class Dtype> cv::Mat caffe::BlobToGrayImage(const caffe::Blob<Dtype>*, int, int, Dtype)’ may not have default arguments [-fpermissive]
const Dtype scale = Dtype(1.0)) {
^
Makefile:595: recipe for target '.build_release/src/caffe/util/util_img.o' failed
make: *** [.build_release/src/caffe/util/util_img.o] Error 1
make: *** Waiting for unfinished jobs....

我们找到这个cpp,打开移动到709行,发现函数定义如下

template <typename Dtype>
cv::Mat BlobToGrayImage(const Blob<Dtype>* blob,
const int n, const int c,
const Dtype scale = Dtype(1.0))

报的错是对于Dtype(1.0)这个赋值,我们在函数里找一找scale这个变量,发现只用到了一处

v1 *= scale;

按照原定义的1.0,这里相当于什么都没有做,为了解决这个问题,我们直接删掉初始化,将定义改为

template <typename Dtype>
cv::Mat BlobToGrayImage(const Blob<Dtype>* blob,
const int n, const int c,
const Dtype scale)

然后将用到scale的句子屏蔽

//v1 *= scale;

即可解决此问题。

5.不支持compute_20的问题

问题显示如下

NVCC src/caffe/solvers/nesterov_solver.cu
nvcc fatal : Unsupported gpu architecture 'compute_20'
Makefile:608: recipe for target '.build_release/cuda/src/caffe/solvers/nesterov_solver.o' failed
make: *** [.build_release/cuda/src/caffe/solvers/nesterov_solver.o] Error 1
make: *** Waiting for unfinished jobs....

这个是因为你的cuda版本比较新,不支持compute_20,因此需要你删掉compute_20和compute_21这两行,即可解决。

6.gpumat.hpp缺失

这个问题比较少见,网上没有找到答案,甚至这个hpp文件官方都没有适合的,问题如下

In file included from src/caffe/layers/resample_layer.cu:11:0:
./include/thirdparty/gpu/gpu.hpp:52:35: fatal error: opencv2/core/gpumat.hpp: No such file or directory
compilation terminated.
Makefile:608: recipe for target '.build_release/cuda/src/caffe/layers/resample_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/resample_layer.o] Error 1
make: *** Waiting for unfinished jobs...

这是没有找到gpu_mat.hpp这个文件,我去OpenCV里找了找,有两个叫这个名字的文件,不过不是/opencv2/core/文件夹下的,试着在gpu.hpp里改一下头文件的引用位置,改成OpenCV里的那两个文件,都会报如下的错误

./include/thirdparty/gpu/gpu.hpp(161): error: identifier "GpuMat" is undefined

说明这两个头文件不是我们需要的,没办法,只能在网上找找了,果然找到了一个github中有,大概看了一眼,貌似是因为OpenCV2中的文件,看来是OpenCV3改动比较大。于是我直接在/usr/local/include/opencv2/core文件夹里面创建了一个gpumat.hpp文件,然后把这个文件的内容复制进去即可,记得加sudo权限。

7.cuda_devptrs.hpp缺失

这个问题跟上面的问题一样,也需要一个新的hpp头文件,我们在网上找到了另一个github,相似的操作,同样的位置直接创建一个cuda_devptrs.hpp文件,然后复制进去。

NVCC src/caffe/layers/resample_layer.cu
In file included from ./include/thirdparty/gpu/gpu.hpp:52:0,
from src/caffe/layers/resample_layer.cu:11:
/usr/local/include/opencv2/core/gpumat.hpp:49:41: fatal error: opencv2/core/cuda_devptrs.hpp: No such file or directory
compilation terminated.
Makefile:608: recipe for target '.build_release/cuda/src/caffe/layers/resample_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/resample_layer.o] Error 1

8.vector没有声明std空间

不知道是不是作者粗心,gpu.hpp里调用了vector,却没有在前面加上std::或者在最前面声明using namespace std;结果产生如下错误

./include/thirdparty/gpu/gpu.hpp(432): error: vector is not a template

太多vector了,不可能一个个加,虽然我很不情愿,但我只能在最前面加一个using namespace std;了,希望作者下次用心,也不知道他是怎么调通的。

9.编译boost

有些地方可能需要boost这个库,而较新的代码都是用c++14编译才能不报错,因此我们先在官网下载boost,然后编译

$ cd boost_1_69_0
$ ./bootstrap.sh
$ ./b2 cxxflags="--std=c++14" -j12
$ sudo ./b2 install

生成的库位于/usr/local/lib目录,默认的头文件在/usr/local/include/boost目录。

[学习笔记]编译sensetime发表的Single View Stereo Matching(SVS)遇到的问题的更多相关文章

  1. blfs(systemv版本)学习笔记-编译安装i3-wm平铺式窗口管理器

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! i3-wm项目的官网:https://i3wm.org/ 首先需要lfs基础上编译安装完整的xorg服务 我的xorg服务编译安 ...

  2. blfs(systemd版本)学习笔记-编译安装gnome桌面组件及应用

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! blfs中的gnome项目地址:http://www.linuxfromscratch.org/blfs/view/stable ...

  3. blfs(systemd版本)学习笔记-编译安装配置dhcpcd

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! dhcpcd项目地址:http://www.linuxfromscratch.org/blfs/view/stable-syst ...

  4. blfs(systemd版本)学习笔记-编译安装openssh软件包

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! openssh项目地址:http://www.linuxfromscratch.org/blfs/view/stable/pos ...

  5. blfs(systemd版本)学习笔记-编译安装sudo并创建普通用户配置sudo权限

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! blfs书中sudo的安装配置章节:http://www.linuxfromscratch.org/blfs/view/stab ...

  6. blfs(systemv版本)学习笔记-编译安装ligtdm显示管理器

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! ligtdm带有显示管理器和登录器,参照我的笔记安装xorg和i3后安装lightdm,就可以组成一个简易的桌面环境了 下面是l ...

  7. blfs(systemv版本)学习笔记-编译安装配置dhcpcd

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! dhcpcd项目地址:http://www.linuxfromscratch.org/blfs/view/8.3/basicne ...

  8. blfs(systemv版本)学习笔记-编译安装openssh软件包

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! openssh项目地址:http://www.linuxfromscratch.org/blfs/view/8.3/postlf ...

  9. blfs(systemv版本)学习笔记-编译安装sudo并创建普通用户配置sudo权限

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! blfs书中sudo的安装配置章节:http://www.linuxfromscratch.org/blfs/view/8.3/ ...

随机推荐

  1. 个人作业2——集大通APP案例分析

    个人作业2——集大通APP案例分析 产品:集大通 我认为这个是我们学校的APP,我们应该支持一下. 一.个人体验 1.下载并使用,描述最简单直观的个人第一次上手体验. ①界面美观,可以感受到丰富的校园 ...

  2. CSS 构造表格

    表格边框 CSS 中设置表格边框,请使用 border 属性: <style type="text/css"> table{ border:1px solid red; ...

  3. python中string格式化

    python中可以对string, int, float等数据类型进行格式化操作.下面举例来说明一些常用操作. 先贴出 python 对 String Formatting Operations 讲解 ...

  4. myFocus 焦点图/轮播插件

    最近产品突然就来个需求,要加轮播图,而且是立马要上线,于是乎发现了一个超级简便好用的轮播图插件myFocus,而且myFocus提供很多种风格,可以选择. 这里是使用说明 http://www.chh ...

  5. BZOJ2281:[SDOI2011]黑白棋(博弈论,组合数学,DP)

    Description 小A和小B又想到了一个新的游戏. 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色. 最左边是白色棋子,最右边是黑色棋子,相邻的棋子颜色不同. 小 ...

  6. Linux - 版本控制系统SVN

    0. 摘要 本文通过搭建SVN多版本库为例,介绍SVN的使用. SVN是一个集中式版本控制系统,在服务端部署中央版本库,所有开发人员客户端连接到中央版本库进行代码的提交和更新. Apache Subv ...

  7. 《Mysql必知必会》笔记

    两年前买的书,因为种种原因一直没看,零碎抽点时间看一遍,感觉对自己有用的就顺手记录下.之后转身就把这本书甩了,因为这本书的内容大多是增删改查语句,不实操只看的话,没有什么意义.而且作为一个测试,其实在 ...

  8. 1549: Navigition Problem (几何计算+模拟 细节较多)

    1549: Navigition Problem Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Su ...

  9. scp 指定端口(转)

    1.注意-P 大写 2.实例 从服务器下载 scp -P 26399 root@104.222.133.88:/home/wwwroot/default/phpmyadmin/save/wordpre ...

  10. Centos7 yum安装Mysql5.7

    1.下载mysql安装源 curl -LO http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 2.安装yum源 ...