Skip to main content

Docker + Nvidia

This guide adds GPU passthrough to the standard Dev Container setup, giving Gazebo and Chrono direct access to your NVIDIA GPU. It works on any Linux machine with an NVIDIA GPU.

1. Install NVIDIA Container Toolkit

note

The toolkit lets Docker access the NVIDIA driver on the host. The commands below are for Ubuntu/Debian. For other distros see the official install guide.

Run this on your host machine:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg

distribution=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -fsSL https://nvidia.github.io/libnvidia-container/libnvidia-container.list \
| sed 's|^deb |deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] |' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list > /dev/null

sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Verify the toolkit can see your GPU:

Terminal
docker run --rm --runtime=nvidia --gpus all nvidia/cuda:12.0-base-ubuntu22.04 nvidia-smi

You should see your GPU listed in the output.

2. Open the NVIDIA devcontainer

There is a dedicated devcontainer configuration at .devcontainer/nvidia/ that layers GPU support on top of the base setup. Use it instead of the default one.

VSCode

Open the repository folder in VSCode. When prompted to Reopen in Container, click the prompt and select NVIDIA from the configuration picker. If the prompt doesn't appear, open the Command Palette (Ctrl+Shift+P) and run Dev Containers: Reopen in Container, then select NVIDIA.

CLI

Terminal
devcontainer up --config .devcontainer/nvidia/devcontainer.json

3. Launch the simulation

Once inside the container, follow the normal Docker guide from the display check onward. The GPU is available automatically — no extra flags needed when running sim.


Jetson-specific setup

Jetson boards ship with NVIDIA drivers pre-installed via L4T. The Container Toolkit installation above still applies.

After installing, configure the board for best simulation performance:

  • Power mode: Switch to MAXN (maximum performance) in nvpmodel or the power mode GUI
  • Fan speed: Set fans to full speed with jetson_clocks --fan or the fan control utility
  • WiFi power management: Disable with sudo iw dev wlan0 set power_save off to reduce latency if using the sim over SSH