Docker container with CUDA + X11(GUI) Support + Ubuntu 22.04
ORB-SLAM3 Dockerized |
---|
![]() |
This guide will walk you through setting up ORB-SLAM3 in a Docker container, running it with a EuRoC dataset, and testing it with different configurations like Monocular, Monocular-Inertial, and Stereo.
Note
After setup, you can attach to the running container and compile code using the ORB-SLAM3 library. This setup is designed for development purposes and testing different configurations.
Important
Communication between ORB-SLAM3 is done with sockets in this example. Real world applications usually use ROS communication protocol.
- Docker installed
- NVIDIA GPU and drivers with CUDA support for GPU acceleration
- X11 server running for displaying graphical applications
Tip
For Windows users, you can use VcXsrv
as your X11 server. Setup instructions are provided in Step 5.
First, build the Docker image:
docker build -t orb_slam3:latest .
Important
Run the container with GPU support and X11 forwarding for graphical output:
docker run -it --gpus all --env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--name orb_slam3_container \
orb_slam3:latest
Inside the container, download and set up the EuRoC MAV dataset:
cd /opt/orb_slam3
# Create directory for dataset
mkdir -p Datasets/EuRoc
cd Datasets/EuRoc/
# Download the dataset
wget -c http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/machine_hall/MH_01_easy/MH_01_easy.zip
# Create a directory for MH_01_easy dataset and extract it
mkdir MH01
unzip MH_01_easy.zip -d MH01/
To run graphical applications inside the container:
apt-get update && apt-get install -y x11-apps
Test the X11 setup:
xclock
[!check] You should see a clock window appear on your screen. If it works, your X11 forwarding is configured correctly.
Navigate to the ORB-SLAM3 directory and run the examples:
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt \
./Examples/Stereo/EuRoC.yaml \
../Datasets/EuRoc/MH01 \
./Examples/Stereo/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereo
Tip
You can also run other configurations like Monocular and Monocular-Inertial by using the respective executables in the Examples directory.
Platform | Setup Instructions |
---|---|
Windows | 1. Download and install VcXsrv 2. During configuration, check the box "Disable access control" 3. Set DISPLAY environment variable in your Docker run command |
Linux | Run these commands:bash<br>export DISPLAY=host.docker.internal:0<br>xhost +<br> |
There are two ways to attach to your running container:
docker exec -it orb_slam3_container bash
- Install the "Dev - Containers" extension
- Press
Ctrl + Shift + P
- Select "Remote-Containers: Attach to Running Container"
- Choose the
orb_slam3_container
- Select
/opt/
as the workspace folder
Tip
To change the workspace folder later, press Ctrl + Shift + P
and select "Remote-Containers: Open Container Configuration File"