How to Use DynaSLAM using Docker? DynaSLAM安装与运行
DynaSLAM:动态场景中的追踪、建图和修复
## Overview
- Build DynaSLAM Docker image
- Start DynaSLAM from Docker container
## Demo
- [DynaSLAM安装与运行](https://www.youtube.com/watch?v=nQjy6cjG-_Y)
- [DynaSLAM 安装与运行(补充)](https://www.youtube.com/watch?v=SGtrUSj5wXg)
- [DynaSLAM: build and run DynaSLAM in Docker (english)](https://www.youtube.com/watch?v=qRhFgEIRs_s)
- [DynaSLAM official video](https://www.youtube.com/watch?v=EabI_goFmQs)
## Build DynaSLAM from Docker
- docker
```sh
sudo docker --version
[sudo] password for yubao:
Docker version 19.03.8, build afacb8b7f0
```
- NVIDIA driver: nvidia-smi
- NVIDIA-docker: nvidia-smi
- docker-compose
```sh
$ docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6
```
- Linux (ubuntu)
E.g.
```sh
$ uname -a
Linux GP65-Leopard-9SD 5.3.0-51-generic #44~18.04.2-Ubuntu SMP Thu Apr 23 14:27:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```
- DynaSLAM Source code
```sh
git clone https://github.com/yubaoliu/DynaSLAM.git
```
- TUM dataset
Download TUM dataset form https://vision.in.tum.de/data/datasets/rgbd-dataset/download#freiburg3_walking_xyz
```sh
wget -c https://vision.in.tum.de/rgbd/dataset/freiburg3/rgbd_dataset_freiburg3_walking_halfsphere.tgz
```
- Useful tools for the RGB-D benchmark
https://vision.in.tum.de/data/datasets/rgbd-dataset/tools
Download associate.py
- Associate rgb and depth image list
```sh
tar zxvf rgbd_dataset_freiburg3_walking_halfsphere.tgz
cd rgbd_dataset_freiburg3_walking_halfsphere
associate.py rgb.txt depth.txt > associations.txt
```
## Build Docker Image
```sh
git clone https://github.com/yubaoliu/DynaSLAM.git
cd DynaSLAM/docker
sudo docker-compose build
```
## Get docker image from Dockerhub
```sh
docker pull yubaoliu/dynaslam:latest
```
## Mount dataset folder
```sh
vim docker/.env`: Modify `DATASET_DIR
```
## Start Docker
```sh
# xhost 控制X server访问权限
xhost +local:root
sudo docker-compose up
```
## Kick of docker container
```sh
sudo docker-compose run dynaslam bash
```
## Get trained model
```sh
cd DynaSLAM/src/python/
wget -c https://github.com/matterport/Mask_RCNN/releases/download/v1.0/mask_rcnn_coco.h5
wget https://github.com/matterport/Mask_RCNN/releases/download/v2.1/mask_rcnn_balloon.h5
```
## Build DynaSLAM Manually
```sh
cd DynaSLAM
chmod +x build.sh
./build.sh
```
- Check MasskRCNN
```sh
DynaSLAM$ python src/python/Check.py
```
## Start DynaSLAM
```sh
run_in_docker.sh
```
## Possible errors
### Error 1: Cannot create container for service dynaslam: Unknown runtime specified nvidia
```sh
docker git:(master) ✗ sudo docker-compose up
[sudo] password for yubao:
Creating network "docker_default" with the default driver
Creating volume "docker_DynaSLAM" with default driver
Creating DynaSLAM ... error
ERROR: for DynaSLAM Cannot create container for service dynaslam: Unknown runtime specified nvidia
ERROR: for dynaslam Cannot create container for service dynaslam: Unknown runtime specified nvidia
ERROR: Encountered errors while bringing up the project.
```
or
```sh
sudo docker-compose up
Creating DynaSLAM ... error
ERROR: for DynaSLAM Cannot create container for service dynaslam: Unknown runtime specified nvidia
ERROR: for dynaslam Cannot create container for service dynaslam: Unknown runtime specified nvidia
ERROR: Encountered errors while bringing up the project.
```
Try ``sudo systemctl restart docker``:
```sh
$ systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-05-02 12:06:19 JST; 18s ago
Docs: https://docs.docker.com
Process: 10123 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE
Main PID: 10123 (code=exited, status=1/FAILURE)
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: docker.service: Service hold-off time over, scheduling restart.
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: Stopped Docker Application Container Engine.
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: docker.service: Start request repeated too quickly.
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: docker.service: Failed with result 'exit-code'.
5月 02 12:06:19 yubao-GP65-Leopard-9SD systemd[1]: Failed to start Docker Application Container Engine.
```
Try:
```sh
sudo systemctl daemon-reload
sudo systemctl restart docker
```
Then
```sh
$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
```
Solution:
Please follow: https://github.com/nvidia/nvidia-container-runtime#docker-engine-setup
**Systemd drop-in file:**
```sh
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/override.conf <
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 71, in
from matplotlib.backends import pylab_setup
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 17, in
line for line in traceback.format_stack()
import matplotlib; matplotlib.use('Agg')
Using TensorFlow backend.
Initializing Mask RCNN network...
./src/python
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:1154: calling reduce_max (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py:1188: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
rgbd_tum: /root/DynaSlam/src/MaskNet.cc:48: DynaSLAM::SegmentDynObject::SegmentDynObject(): Assertion `this->net != NULL' failed.
./run_in_docker.sh: line 1: 18 Aborted (core dumped) ./Examples/RGB-D/rgbd_tum ./Vocabulary/ORBvoc.txt ./Examples/RGB-D/TUM3.yaml /root/Dataset/TUM/freiburg3/rgbd_dataset_freiburg3_walking_xyz /root/Dataset/TUM/freiburg3/rgbd_dataset_freiburg3_walking_xyz/associations.txt ../Mask_RCNN ./output
```
Solution:
download trained cnn model using download_model.sh
## References
- Bilibili [DynaSLAM-MaskRCNN 研习](https://www.bilibili.com/video/BV1XJ411D7Qs/)
- Docker [Docker入门](https://www.bilibili.com/video/BV1GC4y1x76g/)
No comments