How to setup CARLA on a Server for Remote Access

map of the road from above, details on the left, CARLA driving simulator

This blog post provides a comparison of the different options for installing CARLA, detailing the benefits and drawbacks of each option to help you make an informed decision and to ensure the best fit for your project. The post guides you through the setup process for different versions of CARLA and includes clear instructions on how to establish a remote connection. We have used Ubuntu 20.04 and CARLA 0.9.13 for all steps described in this tutorial.

Advantages / Disadvantages of Running CARLA on a Dedicated Machine

Running CARLA on a server possesses both benefits and drawbacks. The main benefit is that you don’t need a powerful GPU for the clients if CARLA runs on a server. Only the server must be equipped with a system that must have a powerful GPU to ensure it can handle and process graphical content smoothly and efficiently for multiple clients. This makes it a much more cost-effective solution.

However, high bandwidth requirements when streaming images from CARLA sensors to clients can produce a delay in real-time applications. This can make the streaming experience laggy and difficult to use. Our experience showed that we could not stream 30 images per second with a 720p resolution in a local network with a bandwidth of 866 Mb/s.

Hence, the decision to run CARLA on a server should be carefully evaluated. If you rely on CARLA images being displayed in real-time, you should consider running CARLA locally. However, for providing a team with developing access to CARLA, it makes sense to install CARLA on a remote server.

CARLA

Finding the Right CARLA Package to Use – Pros and Cons of Using the Docker, Binary, and Source Package of CARLA

Depending on the requirements of your project, CARLA can be installed in different ways. To ensure the best possible outcome for your project, it is essential to select the right package. Two versions of CARLA are available – the binary package version and the source package version. While the binary version contains an executable to start the server, the source version also contains the Unreal editor and the unpackaged assets. Both versions can be used depending on your individual requirements and have their pros and cons. Docker images are generally easier to use as they do not require the user to install any dependencies. The binary docker image is readily available while the docker image with the source code and Unreal editor must be built manually.

The Binary Package Version

The packaged version of CARLA contains a binary to launch the server and is approximately 16 GB in size. From our experience, it showed that it is much easier to import custom maps in the source version, but without that requirement, it is easier to set up the packaged version.

For the Packaged Version we have the following installation methods:

The binary package version offers improved maintenance, stability, and ease of installation. Package managers thoroughly test and update binaries for stability and security, making them a better option than downloading from source code. The pre-compiled installation files allow for easy tracking and automatic downloading of dependencies, making installation simple. Package managers also handle dependency management, making software maintenance and setup easier.

The main drawback of the binary package version is its limited customization options, preventing extensive modifications. Adding custom maps is not easily possible, and it is advisable to use an alternative, such as the source package version if custom maps are a requirement.

The Source Package Version

The source package version of CARLA needs at least 150 GB of storage; however, the CARLA documentation often provides other numbers that are not consistent. The reason for the large storage requirement is due to the Unreal Engine 4 editor being a dependency for this version. Also, the source version does not provide a binary to start the server directly; but you can build a binary for starting the Unreal editor from which the server can be launched. We suggest to build CARLA from source as it is better documented than building the respective Docker image.

Building the software from source allows the user to make changes and modifications to the code and to include their own custom maps in the software. This provides greater flexibility and customization options compared to using pre-compiled binary versions. The user has complete control over the code and can tailor it to their specific needs and requirements.

For the source package version we have the following installation methods:

Source packages offer up-to-date software and user control by allowing users to compile their own software and select features to install. However, installing from source bypasses package managers, leading to potential debugging and resolution issues that may be costly and time-consuming.

CARLA Roads Video

Starting a Remote CARLA Server

If you have installed the source version you have to start the server via the Unreal editor by simply pressing play. In case you have the binary installed do the following.

First, you have to navigate to the folder where CARLA is installed. Then, use the following command to start your server:

./CarlaUE4.sh

Some useful config parameters:

  • -quality-level=<Low/Epic>: Controls the render quality of CARLA. For low-end GPUs, the setting Low is recommended. Possible values are Low and Epic
  • -ResX=<Integer>: Controls the horizontal resolution of the spectator camera. Every time the CARLA server is started, the spectator camera is spawned as well. The camera requires GPU resources, hence set this to 1 if it is not needed.
  • ResY=<Integer>: Same as ResX but for the vertical resolution
  • -RenderOffscreen: Does not create a window showing the output of the spectator cam. Required if CARLA is run on a remote server. Note that the spectator cam is still rendered (just not shown). Thus, it should be paired with -ResX=1 -ResY=1.
  • Setting IP and port: Clients communicate with server via TCP link using host and port specified by the server. ./CarlaUE4.sh --carla-world-port=N. N is usually set as an even number because the server occupies port N+1 for connections.

Problems with Intel integrated GPU and a dedicated GPU

With Ubuntu 22.04 it was common to have problems starting CARLA on GPU. In the terminal when starting CARLA, this warning was shown:

MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0Code language: HTTP (http)

What can help to run CARLA on GPU:

  • Instead of this command ./CarlaUE4.sh you should execute the following:
<code>./CarlaUE4.sh -prefernvidia</code>Code language: HTML, XML (xml)

If this does not work, you can try:

DRI_Prime=1 ./CarlaUE4.sh -quality-level=Epic

If none of the following solve the problem, before starting CARLA, execute the following:

  • Enable the Intel kernel module to allow user space applications to perform GPU based metrics collection. On boot, by default, it does not allow user-space applications to do this:
    Use the following command to manually enable GPU-based metrics collection:
<code>sudo sysctl -w dev.i915.perf_stream_paranoid=0</code>Code language: HTML, XML (xml)

After this, start the CARLA server.

Connecting to a Remote CARLA Server from Outside a Local Network

Since CARLA provides a TCP server, you cannot connect from outside your local network by default. The easiest way to also connect from outside is to set up an ssh tunnel, i.e., connect via ssh to the CARLA server and forward the respective ports (by default 2000, 2001, and 2002):

ssh -L 2000:localhost:2000 -L 2001:localhost:2001 -L 2002:localhost:2002 <USER>@<IP OF REMOTE SERVER>Code language: CSS (css)

Once that is done, another terminal window can be used to establish the connection with CARLA.

Summary

CARLA offers two options for autonomous driving simulation, each with its own level of complexity and flexibility. The packaged version is recommended for a simpler installation and is sufficient for most users. However, the source version provides greater customization and control, although it requires more effort during installation. Choose the packaged version for ease of setup or the source version for maximum customization and control.

Share this Article on Social Media

Facebook
Reddit
Twitter
WhatsApp
LinkedIn
Email
Telegram

Do you have questions about what you just read?
Get in Contact with us!

Thank You!

We have received your message and someone will get back to you shortly!

Let's Start Building
Something Great Together!

Are you ready to get started on the development of your product? Wait no longer! Enter your email below and one of our team members will contact you soon!

This Website Uses Cookies

We use cookies to provide social media features and to analyze our traffic. You can consent to the use of such technologies by closing this notice, by interacting with any link or button outside of this notice, or by continuing to browse otherwise. You can read more about our cookie consent policy here.