Docker Setup for Stretch Simulation with Nvidia GPU Support
This guide provides instructions for setting up and running the Stretch Simulation environment in Docker with Nvidia GPU acceleration.
Prerequisites
Ubuntu host system (22.04 or newer recommended)
Nvidia GPU with CUDA >=12.6 drivers installed
Docker
Minimum 16GB RAM (32GB recommended)
Quick Setup
The following commands will install the Nvidia Container Toolkit, test GPU access, build the Docker image, and run the container:
Follow Install Docker and Install Nvidia Container Toolkit to set up your system.
Run the following commands:
Note: The build process may take 1-2 hours depending on your internet connection and system performance.
# 1. Install Nvidia Container Toolkit
make install-nvidia-toolkit
# 2. Test GPU access
make test-gpu
# 3. Build the Docker image (takes 1-2 hours)
make build
# 4. Run the container
make runAfter you have the container running, you can follow the main README for commands to run the simulation.
If you would like to manually go through the setup steps, please follow the instructions starting at Build the Docker Image.
1. Install Docker
If you don't have Docker installed, run:
2. Install Nvidia Container Toolkit
The Nvidia Container Toolkit allows Docker containers to access your GPU for hardware acceleration.
Verify Nvidia Container Toolkit Installation
Test that GPU access works in Docker:
You should see your GPU information displayed.
3. Build the Docker Image
Navigate to the stretch_simulation directory and build the image:
Note: The build process may take 1-2 hours depending on your internet connection and system performance.
Technical Note: The Dockerfile sets the DOCKER_BUILD=1 environment variable when running the workspace setup script. This enables Docker mode which:
Bypasses sudo checks (running as root is expected in Docker)
Skips interactive prompts for automated builds
Uses the local script instead of downloading from the internet
The same stretch_create_ament_workspace.sh script works in both Docker and manual modes based on the DOCKER_BUILD environment variable.
4. Run the Docker Container
Basic Usage
Run the container with GPU support and X11 forwarding for GUI applications:
Run with Persistent Storage
To persist maps and other data:
Run Specific Launch Commands
Launch the Mujoco driver directly:
5. Using Docker Compose (Optional)
Create a docker-compose.yml file for easier management:
Run with:
6. Common Usage Examples
Navigation with Pre-mapped Scene
Enable Cameras and PointClouds
7. Troubleshooting
GPU Not Detected
If the container can't access the GPU:
X11 Display Issues
If GUI applications don't appear:
OpenGL/EGL Issues
If you encounter OpenGL errors:
8. Performance Tips
Use
--shm-size=2gor higher if you encounter shared memory issuesFor better performance, use
--ipc=hostConsider using
--cpuset-cpusto dedicate specific CPU coresMonitor GPU usage with
nvidia-smiwhile running simulations
9. Cleaning Up
Remove containers and images:
Additional Resources
Last updated
Was this helpful?
