栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ubuntu20.04下dsp-slam的运行配置

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu20.04下dsp-slam的运行配置

这真是我见过最友好的代码,作者直接把配置文件给出来,运行就能把需要的依赖全部安上,帮助文档写的十分详细。
作者是在ubuntu18和20上调试成功的,我电脑是20.04,虽然显卡不一样(我是RTX3060),但是可以很顺利的安装环境。
我事先安装了nvidia驱动、cuda和cudnn,nvida驱动470+cudu11.4+cudnn8.4.0。其实不安装也可以,作者的配置文件是从0配置。
1、下载代码:
#–recursive可不能省掉,不然pybind11载不下来。

git clone --recursive https://github.com/JingwenWang95/DSP-SLAM.git 

2、配置环境
作者的build_cuda102.sh和build_cuda113.sh是帮助配置(从0配置,各种包、anaconda等)的文件,通过终端./build_cuda102.sh或者./build_cuda113.sh即可运行。
我ubuntu刚好是重装的,只安装了驱动和anaconda,完全按照readme中的指示一步步安就好。
配置文件通过代码运行(需自己提前安好anaconda,cuda和mmcv等会在创建的虚拟环境dsp-slam中配置):

 ./build_cuda113.sh --install-cuda --build-dependencies --create-conda-env

如果完全按照配置文件中的版本安装不会遇到任何问题(我用自己原本安装好的cuda11.4运行会报mmcv版本的错,怎么更改版本都不好使。最后还是安了cuda11.3,在虚拟环境里安就好,不用再安驱动。所以说还是要听话啊,配置文件安了什么就乖乖让它安吧), 其内容如下(推荐大家看好注释一块一块安,这样方便看到哪里出错):

#!/bin/bash -e
#
# This is a build script for DSP-SLAM.
#
# Use parameters:
# `--install-cuda` to install the NVIDIA CUDA suite
#
# Example:
#   ./build_cuda113.sh --install-cuda --build-dependencies --create-conda-env
#
#   which will
#   1. Install some system dependencies
#   2. Install CUDA-11.3 under /usr/local
#   3. Create and build:
#   - ./Thirdparty/opencv
#   - ./Thirdparty/eigen
#   - ./Thirdparty/Pangolin
#   4. Build:
#   - ./Thirdparty/g2o
#   - ./Thirdparty/DBoW2
#   5. Create conda env with PyTorch 1.10
#   6. Install mmdetection and mmdetection3d
#   7. Build DSP-SLAM

# Function that executes the clone command given as $1 iff repo does not exist yet. Otherwise pulls.
# Only works if repository path ends with '.git'
# Example: git_clone "git clone --branch 3.4.1 --depth=1 https://github.com/opencv/opencv.git"
function git_clone(){
  repo_dir=`basename "$1" .git`
  git -C "$repo_dir" pull 2> /dev/null || eval "$1"
}

source Thirdparty/bashcolors/bash_colors.sh
function highlight(){
  clr_magentab clr_bold clr_white "$1"
}

highlight "Starting DSP-SLAM build script ..."
echo "Available parameters:
        --install-cuda
        --build-dependencies
        --create-conda-env"

highlight "Installing system-wise packages ..." #这里在安装一些基础的包,g++ cmake什么的,如果已经安装一样的版本可以注释掉这部分。
sudo apt-get update > /dev/null 2>&1 &&
sudo apt -y install gcc-8 g++-8 # gcc-8 is a safe version 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8
sudo apt-get install -y cmake
sudo apt-get install -y 
  libglew-dev 
  libgtk2.0-dev 
  pkg-config 
  libegl1-mesa-dev 
  libwayland-dev 
  libxkbcommon-dev 
  wayland-protocols

# install CUDA 11.3 如果已经安装了更高版本的驱动,这里可以选择不安装驱动
if [[ $* == *--install-cuda* ]] ; then
  highlight "Installing CUDA..."
  wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.19.01_linux.run
  sudo sh cuda_11.3.0_465.19.01_linux.run
  rm cuda_11.3.0_465.19.01_linux.run
fi # --install-cuda
export PATH=/usr/local/cuda-11.3/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH

if [[ $* == *--build-dependencies* ]]; then
  highlight "Installing OpenCV ..."
  cd Thirdparty
  git_clone "git clone --branch 3.4.1 --depth=1 https://github.com/opencv/opencv.git"
  cd opencv
  if [ ! -d build ]; then
    mkdir build
  fi
  cd build
  cmake 
      -DCMAKE_BUILD_TYPE=Release 
      -DWITH_CUDA=OFF  
      -DBUILD_DOCS=OFF  
      -DBUILD_PACKAGE=OFF 
      -DBUILD_TESTS=OFF  
      -DBUILD_PERF_TESTS=OFF  
      -DBUILD_opencv_apps=OFF 
      -DBUILD_opencv_calib3d=ON  
      -DBUILD_opencv_cudaoptflow=OFF  
      -DBUILD_opencv_dnn=OFF  
      -DBUILD_opencv_dnn_BUILD_TORCH_IMPORTER=OFF  
      -DBUILD_opencv_features2d=ON 
      -DBUILD_opencv_flann=ON 
      -DBUILD_opencv_java=ON  
      -DBUILD_opencv_objdetect=ON  
      -DBUILD_opencv_python2=OFF  
      -DBUILD_opencv_python3=OFF  
      -DBUILD_opencv_photo=ON 
      -DBUILD_opencv_stitching=ON  
      -DBUILD_opencv_superres=ON  
      -DBUILD_opencv_shape=ON  
      -DBUILD_opencv_videostab=OFF 
      -DBUILD_PROTOBUF=OFF 
      -DWITH_1394=OFF  
      -DWITH_GSTREAMER=OFF  
      -DWITH_GPHOTO2=OFF  
      -DWITH_MATLAB=OFF  
      -DWITH_NVCUVID=OFF 
      -DWITH_OPENCL=OFF 
      -DWITH_OPENCLAMDBLAS=OFF 
      -DWITH_OPENCLAMDFFT=OFF 
      -DWITH_TIFF=OFF  
      -DWITH_VTK=OFF  
      -DWITH_WEBP=OFF  
      ..
  make -j8
  OpenCV_DIR=$(pwd)
  cd ../..

  highlight "Installing Eigen3 ..."
  git_clone "git clone --branch=3.4.0 --depth=1 https://gitlab.com/libeigen/eigen.git"
  cd eigen
  if [ ! -d build ]; then
    mkdir build
  fi
  if [ ! -d install ]; then
    mkdir install
  fi
  cd build
  cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/../install" ..
  make -j8
  make install
  cd ../..

  highlight "Installing Pangolin ..."
  git_clone "git clone --recursive --depth=1 https://github.com/stevenlovegrove/Pangolin.git"
  cd Pangolin
  if [ ! -d build ]; then
    mkdir build
  fi
  cd build
  cmake ..
  make -j8
  Pangolin_DIR=$(pwd)
  cd ../..

highlight "Installing g2o ..."
  cd g2o
  if [ ! -d build ]; then
    mkdir build
  fi
  cd build
  cmake -DEigen3_DIR="$(pwd)/../../eigen/install/share/eigen3/cmake" ..
  make -j8
  cd ../..

  highlight "Installing DBoW2 ..."
  cd DBoW2
  if [ ! -d build ]; then
    mkdir build
  fi
  cd build
  cmake -DOpenCV_DIR=$OpenCV_DIR ..
  make -j8
  cd ../../..
fi # --build-dependencies

if [[ $* == *--create-conda-env* ]] ; then
  highlight "Creating Python environment ..."
  conda env create -f environment_cuda113.yml
fi # --create-conda-env

conda_base=$(conda info --base)
source "$conda_base/etc/profile.d/conda.sh"
conda activate dsp-slam

highlight "Installing mmdetection and mmdetection3d ..."
pip install pycocotools==2.0.1
pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html
pip install mmdet==2.14.0
pip install mmsegmentation==0.14.1
cd Thirdparty
git_clone "git clone https://github.com/JingwenWang95/mmdetection3d.git"
cd mmdetection3d
pip install -v -e .
cd ../..

highlight "building DSP-SLAM ..."
if [ ! -d build ]; then
  mkdir build
fi
cd build
conda_python_bin=`which python`
conda_env_dir="$(dirname "$(dirname "$conda_python_bin")")"
cmake 
  -DOpenCV_DIR="$(pwd)/../Thirdparty/opencv/build" 
  -DEigen3_DIR="$(pwd)/../Thirdparty/eigen/install/share/eigen3/cmake" 
  -DPangolin_DIR="$(pwd)/../Thirdparty/Pangolin/build" 
  -DPYTHON_LIBRARIES="$conda_env_dir/lib/libpython3.7m.so" 
  -DPYTHON_INCLUDE_DIRS="$conda_env_dir/include/python3.7m" 
  -DPYTHON_EXECUTABLE="$conda_env_dir/bin/python3.7" 
  ..
make -j8

install CUDA 11.3 的部分,如果已经安装了更高版本的驱动,这里可以选择不安装。在continue和accpet之后,把driver前面的x用回车取消掉。安装之后会报一个没有安装驱动的错误,不用管,其实cuda已经安好了。
——————————————————————————————
3、下载数据集与运行
数据集载了好多天,一直失败重新载,太要命了。
以kitti/07为例,压缩包包含如下内容:

在代码根目录下创建data/kitti,把解压后的07文件夹放进去。再在根目录创建一个map/kitti/07,用来放置输出的地图信息。

然后就是运行:

./dsp_slam Vocabulary/ORBvoc.bin configs/KITTI04-12.yaml data/kitti/07 map/kitti/07


map/kitti/07文件夹下会得到三个txt文件(objects文件夹下一步才有):

接下来进行地图提取:

python extract_map_objects.py --config configs/config_kitti.json --map_dir map/kitti/07 --voxels_dim 64

map/kitti/07文件夹下会多一个object的文件夹(即你设置的输出地图信息的位置)。
最后可视化:

python visualize_map.py --config configs/config_kitti.json --map_dir map/kitti/07

4、总结
一个字,乖。任何一步都不要省略,作者安什么你安什么,他什么版本你什么版本。有一个地方版本不一样就会疯狂报错。
配置这么多项目,错误都是版本不一致导致的!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/976859.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号