DS-SLAM 编译安装运行全程记录 RTX2060+CUDA10+CUDNN7

文章目录

  • 我自己的DS-SLAM安装记录
    • 系统版本&硬件
    • CUDA & cudnn
    • ROS Kinetic
      • 遇到的问题
    • opencv + caffe
      • 如果你安装的是caffe-segnet-cudnn7的版本
      • 如果你安装的是caffe-segnet-cudnn5的版本,你可能会遇到如下问题,caffe 与cudnn版本不匹配
      • make runtest 可能出现的问题
      • 其他我遇到的问题
    • OctoMap and RVIZ
      • 遇到的问题
    • ORB-SLAM2 & DS-SLAM
      • 遇到的其它问题
    • 参考资料

我自己的DS-SLAM安装记录

前言:我自己第一次装得时候,编译完成后,roslaunch xx.lauch运行的时候ros总是意外崩溃,使用的是作者的源代码,考虑到可能是环境的问题,也许我之前某些步骤使用了make install,把某些库直接装在的系统中,导致ds找不到与其对应正确的版本,直接读到系统中的库。所以重新装了一次系统,从头开始,从周日下午到周二,总共花费了两天多,在刘阳学弟和黄凯学长的大力帮助下,终于是跑通了原始DS-SLAM,研究学习的第一步复现,算是完成了,下面我将详细的叙述一下这次环境配置过程。再次感谢刘阳和黄凯学长!!
大体流程 nvidia显卡驱动->CUDA10+cudnn7->ros(包含opencv)->caffe-segnet-cudnn7->octomap_mapping+octomao_rviz->DS_SLAM源码

系统版本&硬件

ubuntu 16.04
Intel® Core™ i7-8700 CPU @ 3.20GHz × 12
GeForce RTX 2060/PCIe/SSE2

CUDA & cudnn

一开始我安装的是CUDA9.0,后面编译caffe的时候提示我 cuda9.0不支持compute_75,然后我又重新安装CUDA10.0 以及配套的Cudnn7.3.0 这些安装教程网上比较多,只要注意与自己的显卡算力版本对应即可。
安装完成后,可以输入以下指令,确认自己安装的版本。

1、查看cuda版本

cat /usr/local/cuda/version.txt
#output:
CUDA Version 10.0.130

2、查看cudnn版本

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#output:
MAJOR -A 2
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 3
#define CUDNN_PATCHLEVEL 0
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)#include "driver_types.h"nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

ROS Kinetic

按照官方网站教程,网址在这:http://wiki.ros.org/kinetic/Installation/Ubuntu
还需要安装这个catkin,http://wiki.ros.org/catkin ,记得选kinetic选项
装好之后 http://wiki.ros.org/ROS/Tutorials/CreatingPackage

遇到的问题

问题1:在执行到这两步的时候

# With the following, you can initialize rosdep.
sudo rosdep init
rosdep update

出现的问题

sudo rosdep init ERROR: cannot download default sources list

解决方法

#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133  raw.githubusercontent.com
#保存后退出再尝试

问题2 catkin_make时出现

The imported target “xxx” references the file “/usr/lib/x86_64-linux-gnu/libEGL.so” but this file does not exist. 

解决办法:https://askubuntu.com/questions/616065/the-imported-target-qt5gui-references-the-file-usr-lib-x86-64-linux-gnu-li

opencv + caffe

这里采用的黄凯学长的方法,不单独安装opencv,使用ros里面自带的opencv。
https://blog.csdn.net/abc039510/article/details/103032120

原版DS推荐下载caffe-segnet-cudnn5,我考虑到我自己安装的cudnn版本,我下载的是 https://github.com/navganti/caffe-segnet-cudnn7,
安装在/home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/目录下
需要注意的是,安装caffe的时候 要用cmake,我当初使用make的时候一堆报错,
不知道如何解决,但是使用cmake的时候就不出错了,在caffe-segnet-cudnn7目录下

mkdir build
cd build
cmake ..
# -jx根据自己电脑性能选择,我这台主机可以跑 make all -j12
make all -j12
#测试caffe安装的时候,会跑蛮久
make runtest -j12

如果你安装的是caffe-segnet-cudnn7的版本

记得改一下这几个cmakelists.txt里面的路经,所有跟cudnn5相关的都改成cudnn7

1./home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/CMakeLists.txt 
2./home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/libsegmentation/CMakeLists.txt
3./home/xxx/catkin_ws/src/DS-SLAM/CMakeLists.txt#举个例子 ./home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/CMakeLists.txt
#54行左右 
${PROJECT_SOURCE_DIR}/../../../Examples/ROS/ORB_SLAM2_PointMap_SegNetM/caffe-segnet-cudnn5/include 
${PROJECT_SOURCE_DIR}/../../../Examples/ROS/ORB_SLAM2_PointMap_SegNetM/caffe-segnet-cudnn5/build/include
#更改为
${PROJECT_SOURCE_DIR}/../../../Examples/ROS/ORB_SLAM2_PointMap_SegNetM/caffe-segnet-cudnn7/include 
${PROJECT_SOURCE_DIR}/../../../Examples/ROS/ORB_SLAM2_PointMap_SegNetM/caffe-segnet-cudnn7/build/include
#也就是把5改成7即可。

如果你安装的是caffe-segnet-cudnn5的版本,你可能会遇到如下问题,caffe 与cudnn版本不匹配

报错信息如下

 ./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function

解决办法:

 1.将./include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.2将./include/caffe/layers里的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp。   都替换成最新版的caffe里的相应的同名文件。3.将./src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。都替换成最新版的caffe里的相应的同名文件。

详细的caffe安装步骤可以参考
https://blog.csdn.net/yhaolpz/article/details/71375762
中的第9步安装 caffe。

make runtest 可能出现的问题

F0608 21:45:54.079473  3250 cudnn_softmax_layer.cu:20] Check failed: status == CUDNN_STATUS_SUCCESS (32 vs. 0)  CUDNN_STATUS_EXECUTION_FAILED
Aborted (core dumped)
src/caffe/test/CMakeFiles/runtest.dir/build.make:57: recipe for target 'src/caffe/test/CMakeFiles/runtest' failed
make[3]: *** [src/caffe/test/CMakeFiles/runtest] Error 134
CMakeFiles/Makefile2:328: recipe for target 'src/caffe/test/CMakeFiles/runtest.dir/all' failed
make[2]: *** [src/caffe/test/CMakeFiles/runtest.dir/all] Error 2
CMakeFiles/Makefile2:335: recipe for target 'src/caffe/test/CMakeFiles/runtest.dir/rule' failed
make[1]: *** [src/caffe/test/CMakeFiles/runtest.dir/rule] Error 2
Makefile:240: recipe for target 'runtest' failed
make: *** [runtest] Error 2

解决办法

我一开始安装cunn7.6.4遇到的,修改cudnn 从7.6.4 改成7.5解决,我第二次装得是cudnn7.3.6,也没遇到过这个问题

其他我遇到的问题

问题1

/usr/bin/ld: .build_release/lib/libcaffe.so: undefined reference to symbol '_ZNK2cv9Exception4whatEv'
/usr/lib/x86_64-linux-gnu/libopencv_core.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:637: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed
make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1

解决办法,使用cmake即可。

问题2

In file included from /home/xxx/ds-slam/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/libsegmentation/libsegmentation.cpp:34:0:
/home/xxx/ds-slam/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/libsegmentation/libsegmentation.hpp:37:27: fatal error: caffe/caffe.hpp: No such file or directory
compilation terminated.
CMakeFiles/segmentation.dir/build.make:62: recipe for target 'CMakeFiles/segmentation.dir/libsegmentation.cpp.o' failed

解决办法:https://blog.csdn.net/yinghuaxuan/article/details/89969197

OctoMap and RVIZ

安装官方要求,先下载 https://github.com/OctoMap/octomap_mapping and https://github.com/OctoMap/octomap_rviz_plugins.
下载到 catkin_ws/src下,
然后

sudo apt-get install ros-kinetic-octomap  ros-kinetic-octomap-msgs ros-kinetic-octomap-ros ros-kinetic-octomap-rviz-plugins 
#注意,有两个包不用装,ros-kinetic-octomap-mapping 和ros-kinetic-octomap-server,这两个包我们已经手动下载到,catkin_ws/src下

然后参考黄凯学长的方法,(原作者没写2)

1.打开头文件开关#define COLOR_OCTOMAP_SERVER,文件路径(catkin_ws/src/octomap_mapping/octomap_server/include/octomap_server/octomapServer.h)
2.彩色八叉地图参数设置:<param name="colored_map" type="bool" value="True" />,文件路径
(/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM/launch/Octomap.launch)

然后catkin_make即可

遇到的问题

问题1
运行ds的时候报错

Error:cannot launch node of type [map_server/map_server]: can't locate node [map_server]  类似的错误

解决办法,切换工作空间

source ~/catkin_ws/devel/setup.bash 

问题2
运行ds如果报错

Colored map requested in launch file - node not running/compiled to support colors, please define COLOR_OCTOMAP_SERVER and recompile or launch the octomap_color_server node this is line 127"

解决办法,要么是忘记打开头文件开关#define COLOR_OCTOMAP_SERVER,要么是使用sudo apt-get install ros-kinetic-octomap-server,导致ros找到了系统里的 octomap-server, 卸载掉 sudo apt-get remove ros-kinetic-octomap-server。 让ros找到我们装在catkin_ws/src下的octomap_mapping包。

ORB-SLAM2 & DS-SLAM

需按照github提供的链接下载Thirdparty and Vocabulary(provided at https://pan.baidu.com/s/1-zWXlzOn-X0tjoEF9XI6qA, extract code: 8t7x)。如果用自己的,可能会出现后缀名不同的情况。这里直接编译会出现orb词典错误,需按照TemplatedVocabulary.h或者TemplatedVocabulary.h(高翔)替换第三方库中的DBoW2库中相对应的文件,因为DS-SLAM给的第三方库中的该文件下定义的类中没有对应的loadFromBinaryFile(strVocFile)成员函数。
原文链接:https://blog.csdn.net/weixin_43823054/java/article/details/104611324

我在装DS-slam 之前,忘记安装pangolin ,记得不要把这个装在catkin_ws/src 里,不然每次安装的时候就需要 catkin_make_isolated,虽然不影响,但是编译输出挺多的。
这部分就是在上面的安装步骤都完成之后,运行

cd DS-SLAM
chmod +x DS_SLAM_BUILD.sh
./DS_SLAM_BUILD.sh

TUM生成之后,修改 PATH_TO_SEQUENCE & PATH_TO_SEQUENCE/associate.txt in the DS_SLAM_TUM.launch,然后运行

cd DS-SLAM
roslaunch DS_SLAM_TUM.launch 

会有一个RVIz的程序运行,选择左下角的add,选择by topic,选择occupied_cells_vis_array下的MarkerArray,就可以复现成功啦。
结果长这样

遇到的其它问题

  1. Anaconda与ROS不兼容问题解决办法
    https://www.cnblogs.com/hgl0417/p/11562580.html
  2. 问题如下
  [rosbuild] Building package ORB_SLAM2_PointMap_SegNetM
Failed to invoke /opt/ros/kinetic/bin/rospack deps-manifests ORB_SLAM2_PointMap_SegNetM
ImportError: No module named rosdep2.rospack
[rospack] Error: could not find python module 'rosdep2.rospack'. is rosdep up-to-date (at least 0.10.4)?CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:129 (message):Failed to invoke rospack to get compile flags for package'ORB_SLAM2_PointMap_SegNetM'.  Look above for errors from rospack itself.Aborting.  Please fix the broken dependency!Call Stack (most recent call first):/opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)CMakeLists.txt:4 (rosbuild_init)

使用批处理 DS_SLAM_BUILD.sh 可解决。

Traceback (most recent call last):File "/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 46, in <module>raise Exception
Exception
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):[rosbuild] rospack found package "ORB_SLAM2_PointMap_SegNetM" at "", butthe current directory is"/home/xxx/catkin_ws/src/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM".You should double-check your ROS_PACKAGE_PATH to ensure that packages arefound in the correct precedence order.

解决办法:export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/DS-SLAM/Examples/ROS/ORB_SLAM2_PointMap_SegNetM
PATH为catkin_ws/src的路经。

写的还是有点乱的,希望能对大家有所帮助,有问题可以问我,如果我还记得:)。20200617

参考资料

有些我已经在上面列过了,下面是我主要的参考资料。

  1. https://blog.csdn.net/yinghuaxuan/article/details/89969197
  2. https://blog.csdn.net/yhaolpz/article/details/71375762
  3. https://blog.csdn.net/abc039510/article/details/103032120
  4. https://blog.csdn.net/weixin_43823054/java/article/details/104611324
  5. https://blog.csdn.net/u013468614/article/details/102917569

本文链接:https://my.lmcjl.com/post/13123.html

展开阅读全文

4 评论

留下您的评论.