Note: Carla has official instructions for docker. Caution that as of Nov 2023, this link builds carla with ubuntu 18 so may not be compatible for other packages such as ROS2.
This repo provide a more compatible docker using either Debian Installation , which supports up to 0.9.13 as of last checking, and Package Installation, which supports up to the latest version.
- base image: nvidia/vulkan:1.3-470 (ubuntu 20.04, python 3.8)
- cuda 11.4
Similar to carla official docker prerequisites
Build the docker locally (may take a very long time)
sudo docker build -t cisl/carla_deb:0.9.13 --file ./carla_deb.Dockerfile .
sudo docker build -t cisl/carla:0.9.15 --file ./carla.Dockerfile .
Or pull the prebuilt carla_deb image, or prebuilt carla image.
- Run the carla server
sudo docker run --privileged --gpus all --net=host -e DISPLAY=$DISPLAY \
-v /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d \
cisl/carla:0.9.15 \
/bin/bash CarlaUE4.sh
- Clone the carla repo, then run the carla client without docker (tested with ubuntu22.04 and python3.10)
pip3 install carla==0.9.15 ### install carla PythonAPI PyPi package
python3 <path-to-carla-root>/PythonAPI/examples/manual_control.py
sudo docker build -t cisl/carla_client --file ./carla_ro2_client.Dockerfile .
Note: the client docker does not have manual_control.py script built in. Need to clone separately.
When running the client docker, remember to also give full network and display access.
sudo docker run -it --rm --net=host -e DISPLAY=$DISPLAY cisl/carla_client
- run carla client with manual control
sudo docker run -it --privileged --gpus all --net=host -e DISPLAY=$DISPLAY \
-v /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d \
cisl/carla:0.9.15 \
/bin/bash
- In docker, run
python3.7 ./PythonAPI/examples/manual_control.py
TODO: direct launch python in deb docker 0.9.13 is working, launching python3.7 from package docker 0.9.15 is not working.
Build the docker locally. The scenario docker image is built on top of the carla image. Get the carla image first before proceeding.
sudo docker build -t cisl/srunner:0.9.15 --file ./srunner.Dockerfile .
Or pull the prebuilt image.
Start the carla server
sudo docker run --privileged --gpus all --net=host -e DISPLAY=$DISPLAY \
-v /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d \
cisl/carla:0.9.15 \
/bin/bash CarlaUE4.sh
Run a scenario,
sudo docker run -it --privileged --gpus all --net=host -e DISPLAY=$DISPLAY \
-v /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d \
cisl/srunner:0.9.15 \
/bin/bash
In the docker, run
python3.7 scenario_runner.py --scenario FollowLeadingVehicle_1 --reloadWorld
This starts the scenario FollowLeadingVehicle_1. Check out more scenarios to run.
Now start a manual control agent
sudo docker run -it --privileged --gpus all --net=host -e DISPLAY=$DISPLAY \
-v /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d \
cisl/srunner:0.9.15 \
/bin/bash
In the docker, run
python3.7 manual_control.py
Note: This is the manual_control from the scenario runner, not exactly the same one from carla/PythonAPI/example mentioned above.
The task of this scenario FollowLeadingVehicle_1 is to drive behind the leading vehicle and finish the road segment.
After finishing the task, or timed out (timer starts from scenario launch, not manual_control launch), the scenario will terminate itself.