2020-03-02 16:40:34 +08:00
# Running CARLA in a Docker
2018-07-21 04:52:11 +08:00
2020-09-06 19:43:19 +08:00
* [__Docker installation__ ](#docker-installation )
* [Docker CE ](#docker-ce )
* [NVIDIA-Docker2 ](#nvidia-docker2 )
* [__Running CARLA container__ ](#running-carla-container )
2020-03-11 22:42:41 +08:00
2018-07-21 04:52:11 +08:00
This tutorial is designed for:
2020-03-11 22:42:41 +08:00
* People that want to run CARLA without needing to install all dependencies.
* Recommended solution to run multiple CARLA servers and perform GPU mapping.
* People who don't need to render the full simulation (the server is headless).
2018-07-21 04:52:11 +08:00
This tutorial was tested in Ubuntu 16.04 and using NVIDIA 396.37 drivers.
2018-07-31 01:18:41 +08:00
This method requires a version of NVIDIA drivers >=390.
2018-07-21 04:52:11 +08:00
2018-07-21 04:52:11 +08:00
2020-03-02 16:40:34 +08:00
---
2020-03-02 21:35:50 +08:00
## Docker Installation
2018-07-21 04:52:11 +08:00
!!! note
Docker requires sudo to run. Follow this guide to add users to the docker sudo
2019-06-27 16:26:32 +08:00
group < https: / / docs . docker . com / install / linux / linux-postinstall / >
2018-07-21 04:52:11 +08:00
2020-03-11 22:42:41 +08:00
### Docker CE
2018-07-21 04:52:11 +08:00
For our tests we used the Docker CE version.
2019-09-06 17:07:21 +08:00
To install Docker CE we recommend using [this tutorial][tutoriallink]
[tutoriallink]: https://docs.docker.com/install/linux/docker-ce/ubuntu/#extra-steps-for-aufs
2018-07-21 04:52:11 +08:00
2020-03-11 22:42:41 +08:00
### NVIDIA-Docker2
2018-07-21 04:52:11 +08:00
2020-03-11 22:42:41 +08:00
To install nvidia-docker-2 we recommend using the "Quick Start" section from the [nvidia-dockers github ](https://github.com/NVIDIA/nvidia-docker ).
2018-07-21 04:52:11 +08:00
2020-03-02 16:40:34 +08:00
---
2020-03-11 22:42:41 +08:00
## Running CARLA container
2018-07-21 04:52:11 +08:00
Pull the CARLA image.
2019-09-06 17:07:21 +08:00
```sh
docker pull carlasim/carla:version
```
2018-07-31 01:18:41 +08:00
2021-02-08 17:29:01 +08:00
To select a specific version:
2018-07-31 01:18:41 +08:00
2019-09-06 17:07:21 +08:00
```sh
2021-02-08 17:29:01 +08:00
docker pull carlasim/carla:0.9.11
2019-09-06 17:07:21 +08:00
```
2018-07-21 04:52:11 +08:00
2020-03-11 22:42:41 +08:00
Running CARLA under docker.
2018-07-21 04:52:11 +08:00
2019-09-06 17:07:21 +08:00
```sh
2020-03-20 01:49:50 +08:00
docker run -p 2000-2002:2000-2002 --runtime=nvidia --gpus all carlasim/carla:0.8.4
2019-09-06 17:07:21 +08:00
```
2018-07-21 04:52:11 +08:00
2019-09-06 17:07:21 +08:00
The `-p 2000-2002:2000-2002` argument is to redirect host ports for the docker container.
2020-02-25 17:31:14 +08:00
Use `--gpus '"device=<gpu_01>,<gpu_02>"'` to specify which GPUs should run CARLA. Take a look at this [NVIDIA documentation ](https://github.com/NVIDIA/nvidia-docker ) to learn other syntax options.
2018-07-21 04:52:11 +08:00
2020-03-11 22:42:41 +08:00
You can also pass parameters to the CARLA executable. With this you can chose the town and select the port that is going to be used.
2018-07-21 04:52:11 +08:00
2019-09-06 17:07:21 +08:00
```sh
docker run -p 2000-2002:2000-2002 --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 carlasim/carla:0.8.4 /bin/bash CarlaUE4.sh < Your list of parameters >
```
2018-07-31 01:18:41 +08:00
2020-03-11 22:42:41 +08:00
At the list of parameters do not forget to add `-world-port=<port_number>` so that CARLA runs on server mode listening to the `<port_number>` .