ubuntu14.04 CUDA8.0 DynSLAM编译与运行

本文介绍2018年的一篇基于深度学习,同时具有稠密地图的视觉SLAM------Dynslam.

标题:Robust Dense Mapping for Large-Scale Dynamic Environments

在这里可以找到文章主页和源代码:http://andreibarsan.github.io/dynslam

在这里找到编译方法和部分错误解决方案:https://blog.****.net/wujie_13143/article/details/81667703

按照github上的编译,下面介绍编译过程中的其它错误和解决方案:

(1)安装nvidia-docker2:

    1:docker-ce安装(由于我在直接安装nvidia-docker2时报错,说是这个没有安装,那就先装一下吧O_O):
        # step 1: 安装必要的一些系统工具
        sudo apt-get update
        sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
        # step 2: 安装GPG证书
        curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
        # Step 3: 写入软件源信息
        sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
        # Step 4: 更新并安装 Docker-CE
        sudo apt-get -y update
        sudo apt-get -y install docker-ce

        # 安装指定版本的Docker-CE:(没试过)
        # Step 1: 查找Docker-CE的版本:
        # apt-cache madison docker-ce
        #   docker-ce | 17.03.1~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
        #   docker-ce | 17.03.0~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
        # Step 2: 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.1~ce-0~ubuntu-xenial)
        # sudo apt-get -y install docker-ce=[VERSION]
    2:获取权限(可以避免使用docker时添加sudo):
        sudo groupadd docker     #添加docker用户组
        sudo gpasswd -a $USER docker     #将登陆用户加入到docker用户组中
        newgrp docker     #更新用户组
        docker ps    #测试docker命令是否可以使用sudo正常使用
    3:安装校验:
        docker version
    4:安装nvidia-docker2("\"表示换行):
        docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
        sudo apt-get purge -y nvidia-docker

        curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
        sudo apt-key add -

        distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

        curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
        sudo tee /etc/apt/sources.list.d/nvidia-docker.list

        sudo apt-get update

        sudo apt-get install -y nvidia-docker2
        sudo pkill -SIGHUP dockerd
    5:测试:
        docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

第五步由于时间太长,我就没有测试了O_O

(2)编译Pangolin

1:编译出现-fPIC之类的错误的话,我的原因是安装python3时没有设置这个选项,重新安装python3

./configure --prefix=/usr/local/ CFLAGS=-fPIC 
make
make install

就不会报错了.

2:编译时如果出现examples和tools文件编译错误,注释掉CMakeLists里面的内容就行,不影响.

#if(BUILD_EXAMPLES)
  #set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
  #add_subdirectory(examples)
  #add_subdirectory(tools)
#endif()

(3)代码编译:

错误可根据此博客解决:https://blog.****.net/wujie_13143/article/details/81667703

(4)运行:

bash mkdir -p csv

./build/DynSLAMGUI --use_dispnet --dataset_root=data/mini-seq-06 --dataset_type=kitti-odometry

出现错误cudaSafeCall() Runtime API error : 2 | out of memory,原因可能是内存不够

我的解决方法是:搜索ITMLocalVBA.h,强制设置blockSize大小为64

ITMLocalVBA(MemoryDeviceType memoryType, int noBlocks, int blockSize)
{
	this->memoryType = memoryType;

	blockSize = 64;//强制改变

	allocatedSize = noBlocks * blockSize;

	printf("Building local VBA for storing the active map. noBlocks = %d, blockSize = %d\n",noBlocks, blockSize);
	voxelBlocks = new ORUtils::MemoryBlock<TVoxel>(allocatedSize, memoryType);
	allocationList = new ORUtils::MemoryBlock<int>(noBlocks, memoryType);
}

然后找到ITMLibDefines.h,设置如下:

#define SDF_BLOCK_SIZE 4				// SDF block size
#define SDF_BLOCK_SIZE3 64				// SDF_BLOCK_SIZE3 = SDF_BLOCK_SIZE * SDF_BLOCK_SIZE * SDF_BLOCK_SIZE

然后编译运行就可以跑起来了,下面效果图:

ubuntu14.04 CUDA8.0 DynSLAM编译与运行

还不错,哈哈,以上只是我遇到的情况,在此祝大家都能成功!!!!!