ubuntu16.04下dyna-slam编译运行

ubuntu16.04下dyna-slam编译运行

  • 1. 显卡驱动安装
  • 2. cuda安装
    • cuda与cudnn换版本可参考
  • 3. cudnn安装
  • 4. ORB_SLAM2依赖
      • 4.1 安装Pangolin
      • 4.2 安装OpenCV-2.4.11
      • 4.3 安装Eigen3.1.0
      • 4.4 安装keras2.0.8
      • 4.5 安装Tensorflow
      • 4.6 安装MaskRCNN
      • 4.7 安装pycocotools
  • 5. 编译运行DynaSLAM
  • 6. 参考文章

1. 显卡驱动安装

驱动下载链接

nouveau是16系统默认的第三方开源程序,不禁用后面会与NVIDIA显卡驱动安装发生冲突报错
在文档最后面添加以下内容用来禁用

sudo gedit /etc/modprobe.d/blacklist.conf
blacklist nouveau
options nouveau modeset=0

重启

sudo update-initramfs -u
reboot

提前下载好显卡驱动放在/home
准备两台设备
ctrl+alt+f1 进入命令行界面

sudo service lightdm stop
sudo apt-get remove nvidia-*
sudo chmod  a+x NVIDIA-Linux-x86_64-470.63.01.run
sudo ./NVIDIA-Linux-x86_64-470.63.01.run -no-x-check -no-nouveau-check

continue installation
yes
ok

sudo service lightdm start 

ctrl+alt+f7回到登录界面

查看是否安装完成

nvidia-smi  

ubuntu16.04下dyna-slam编译运行_第1张图片


2. cuda安装

cuda与cudnn换版本可参考

sudo chmod a+x cuda_8.0.61_375.26_linux.run
sudo sh cuda_8.0.61_375.26_linux.run

部分选择
accept
是否安装显卡驱动 : n
yes
yes
yes

sudo gedit ~/.bashrc

在文件中添加:

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

查看cuda:

sudo apt install nvidia-cuda-toolkit
nvcc -V

在这里插入图片描述


3. cudnn安装

nvidia官网下载
cudnn6.0 for cuda8.0
cuDNN v6.0 Library for Linux

sudo tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz

解压后会出现一个cuda文件夹

cd cuda
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

查看cudnn版本:

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

ubuntu16.04下dyna-slam编译运行_第2张图片


4. ORB_SLAM2依赖

4.1 安装Pangolin

sudo apt-get install libglew-dev
sudo apt-get install cmake
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
make -j12
sudo make install
  • 出现链接库不存在时
sudo rm  /usr/lib/x86_64-linux-gnu/libGL.so
sudo ln -s  /usr/lib/libGL.so.1  /usr/lib/x86_64-linux-gnu/libGL.so

4.2 安装OpenCV-2.4.11

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
cd opencv-2.4.11
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DWITH_CUDA=OFF ..
make -j12
sudo make install

4.3 安装Eigen3.1.0

cd eigen-3.1.0
mkdir build
cd build
cmake ..
sudo make install
sudo cp -r /usr/local/include/eigen3 /usr/include 

4.4 安装keras2.0.8

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python2 get-pip.py
sudo apt update
sudo apt install --no-install-recommends python2.7-minimal python2.7  
sudo apt install python-numpy python-scipy
sudo pip2 install keras==2.0.8

4.5 安装Tensorflow

下载Tensorflow-gpu文件:

https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-1.4.0rc1-cp27-none-linux_x86_64.whl

pip2 install numpy==1.16.1
pip2 install Markdown==2.6.8

sudo pip2 install tensorflow_gpu-1.4.0rc1-cp27-none-linux_x86_64.whl
  • 测试tensorflow,输出hello则完成
python
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
sess.run(hello)
  • 可能出现的错误:
  • 1、ImportError: libcusolver.so.8.0: cannot open shared object
    file: No such file or directory
sudo ldconfig /usr/local/cuda/lib64
  • 2、import moudle error! no moudle named mock.
pip install mock==0.8.0

4.6 安装MaskRCNN

git clone https://github.com/matterport/Mask_RCNN.git
cd Mask_RCNN
  • 因为已经安装好TensorFlow1.4和Keras2.0.8,需要将requirements.txt中的这两项去掉
  • 依次安装:
pip2 install cpython
sudo apt-get install python-matplotlib
pip2 install future

pip install --upgrade pip

pip install pillow==4.3.0
pip install scikit-image==0.11.3
python -m pip install opencv-python==4.2.0.32

pip install h5py
pip install imageio==2.6.1
pip2 install matplotlib==2.0.0
pip install imgaug

pip2 install notebook
pip2 install qtconsole
pip2 install ipywidgets
pip2 install Sphinx

sudo pip2 install -r requirements.txt

4.7 安装pycocotools

git clone https://github.com/waleedka/coco.git
cd coco/PythonAPI
make
pip install pycocotools

5. 编译运行DynaSLAM

下载dynaslam

wget https://github.com/BertaBescos/DynaSLAM/tree/bbescos/feature/carla

将coco/PythonAPI下的pycocotools文件夹和mask_rcnn_coco.h5放到Dynaslam的src/python目录下。

打开Check.py,将第17行的ROOT_DIR = “src/python”,改为ROOT_DIR = “./”,保存退出。

python Check.py

显示maskrcnn is correct

  • 如果显示 ImportError: libcusolver.so.8.0: cannot open shared object file:
    No such file or directory
sudo ldconfig /usr/local/cuda/lib64

DynaSLAM、/Thirdpary/DBoW2和/Thirdparty/g2o三个文件夹下的CMakeLists.txt 将-march=native删除

  • Viewer.cc中Run()函数中
cv::imshow("DynaSLAM: Current Frame",im);
cv::imshow("DynaSLAM: Dynamic Frame", im_dyn)

修改为:

if(!im.empty())
{
    cv::imshow("DynaSLAM: Current Frame",im);
}

if(!im_dyn.empty())
{
    cv::imshow("DynaSLAM: Dynamic Frame", im_dyn);
}
cd DynaSLAM	
sudo apt-get install cmake qt5-default qtcreator
bash  build.sh
  • 如果显示libEGL.so no exist
cd /usr/lib/x86_64-linux-gnu/
sudo rm libEGL.so
sudo ln -s libEGL.so.1.1.0 libEGL.so
bash  build.sh
  • 如果显示 boost 库问题升级 cmake 和安装 boost

安装升级参考链接

  • 在DynaSLAM根目录中新建data文件夹,在data文件夹中再新建两个文件夹mask和output
  • 数据集放在data里面
  • 下载 associate.py 放入数据集的根目录
python associate.py rgb.txt depth.txt > associated.txt
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt ./Examples/RGB-D/TUM3.yaml ./data/rgbd_dataset_freiburg3_walking_rpy/ ./data/rgbd_dataset_freiburg3_walking_rpy/associated.txt ./data/mask ./data/output


6. 参考文章

https://blog.csdn.net/weixin_43951792/article/details/117168783
https://blog.csdn.net/u011622208/article/details/115955663
https://blog.csdn.net/qq_42938987/article/details/83795217
https://blog.csdn.net/zbr794866300/article/details/106564588
https://blog.csdn.net/DD_PP_JJ/article/details/113822166

你可能感兴趣的:(ubuntu,slam,tensorflow,opencv)