CARLA in Docker
Users can pull an image based on a CARLA release to run in a Docker container. This is useful for users who:
- Want to run CARLA without needing to install all dependencies
- Run multiple CARLA servers and perform GPU mapping
- Run the CARLA server without a display
This tutorial explains the requirements to run the CARLA image and how to run it with or without a display.
Before you begin
You will need to have installed:
- Docker: Follow the installation instructions here.
- NVIDIA Container Toolkit: The NVIDIA Container Toolkit is a library and toolset that exposes NVIDIA graphics devices to Linux containers. It is designed specifically for Linux containers running on Linux host systems. Install the
nvidia-container-toolkitpackage by following the instructions here.
Note
Docker requires sudo to run. Follow this guide to add users to the docker sudo group.
Running CARLA in a container
1. Pull the CARLA image.
You can pull either the latest CARLA image or a specific release version. The latest image refers to the most recent packaged release. To pull the image, run one of the following commands:
# Pull the latest image
docker pull carlasim/carla:latest
# Pull a specific version
docker pull carlasim/carla:0.9.16
2. Run the CARLA container.
Note
The way CARLA is executed inside a Docker container has changed over time. If you are using a version earlier than 0.9.16, please refer to the documentation for that specific version.
Running CARLA without display:
docker run \
--runtime=nvidia \
--net=host \
--env=NVIDIA_VISIBLE_DEVICES=all \
--env=NVIDIA_DRIVER_CAPABILITIES=all \
carlasim/carla:0.9.16 bash CarlaUE4.sh -RenderOffScreen -nosound
Running CARLA with a display:
Note
To run the Docker image with a display, you will need the x11 display protocol.
docker run \
--runtime=nvidia \
--net=host \
--user=$(id -u):$(id -g) \
--env=DISPLAY=$DISPLAY \
--env=NVIDIA_VISIBLE_DEVICES=all \
--env=NVIDIA_DRIVER_CAPABILITIES=all \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
carlasim/carla:0.9.16 bash CarlaUE4.sh -nosound
Any issues or doubts related with this topic can be posted in the CARLA forum.