This document provides solutions to common issues encountered when setting up ROS 2 Iron + Gazebo Garden + CUDA in Docker (WSL2).
nvidia-smi
Not Detecting GPU Inside DockerRunning nvidia-smi
inside the container returns:
Failed to initialize NVML: Driver/library version mismatch
or
NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver
wsl --shutdown
Then, update drivers from:
docker run --rm --gpus all nvidia/cuda:12.2-base nvidia-smi
nvidia-container-toolkit
inside WSL:
sudo apt update
sudo apt install -y nvidia-container-toolkit
Running glxinfo -B
inside the container shows:
OpenGL renderer string: llvmpipe (LLVM 13.0.0, 256 bits)
instead of NVIDIA.
libgl1-mesa-glx
and Vulkan drivers are installed inside WSL:
sudo apt install -y libgl1-mesa-glx libvulkan1 mesa-vulkan-drivers vulkan-tools
wsl --shutdown
glxinfo -B
It should now show:
OpenGL renderer string: NVIDIA
Running gz sim -v 4
does not open the GUI.
echo $DISPLAY
If empty, restart WSL:
wsl --shutdown
wsl
docker-compose.yml
has the correct X11 and WSLg environment:
```yaml
environment:
nvidia-smi
)Gazebo is running, but nvidia-smi
does not show it using the GPU.
export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA
gz sim -v 4
nvidia-smi
again in another terminal inside the container:
nvidia-smi
docker attach
Freezes the TerminalAfter running docker attach ros2-gpu-container
, the terminal freezes when running commands.
docker exec -it ros2-gpu-container bash
Ctrl + P
then Ctrl + Q
For more advanced issues, check Docker logs with:
docker logs ros2-gpu-container