Your Guide to Setting Up the CARLA RL Project

Jul 13, 2024 | Data Science

If you’re venturing into the world of Reinforcement Learning (RL) and have chosen the CARLA simulator, you’re in for an exhilarating ride. This guide will walk you through the installation and setup processes, as well as running the CARLA server and client. Let’s get started!

Installation and Setup

The first crucial step is to install the CARLA simulator, which is best done using a Docker container. As they say, “it’s all about building bridges,” and Docker is the bridge connecting you to the CARLA environment.

Running the CARLA Server

To get the CARLA simulator up and running smoothly, follow these steps:

  • Pull the CARLA Docker image:
  • docker pull carlasim/carla:0.8.2
  • Build your custom CARLA server image:
  • docker build server -t carla-server
  • Run the Docker container with the modified timeout settings:
  • nvidia-docker run --rm -it -p 2000-2002:2000-2002 carlasim/carla:0.8.2 bin/bash

**Note**: Ensure you have nvidia-docker installed, as you will need a GPU for this setup!

Inside the Docker container, execute the following command to start the server:

CarlaUE4.sh Game/Maps/Town01 -carla-server -benchmark -fps=15 -windowed -ResX=800 -ResY=600

If you plan on running multiple servers, we recommend using the script serverrun_servers.py:

python serverrun_servers.py --num-servers N

Logs for stdout and stderr will be under the server_output folder. To check the server’s output, you can use:

docker logs -ft CONTAINER_ID

Running the Client (Training Code, Benchmark Code)

Our solution requires the following dependencies:

  • Python 3
  • PyTorch
  • OpenAI Gym
  • OpenAI Baselines

The easiest way to install these dependencies is via our specially provided Dockerfile. Build it with:

docker build client -t carla-client

To run the client, execute:

nvidia-docker run -it --network=host -v $PWD:app carla-client bin/bash

The --network=host flag enables requests to the server from the Docker container. Now, you can run our scripts like this:

python clienttrain.py --config clientconfigbase.yaml

Arguments and Config Files

The clienttrain.py script requires both arguments and a configuration file to set up and reproduce results.

Hyperparameter Tuning

For testing various hyperparameters, use the:

tests_hyperparameters_parallel.py

Benchmark Results

To reproduce specific benchmarks, follow the commands below based on the desired model:

  • A2C: python clienttrain.py --config clientconfiga2c.yaml
  • ACKTR: python clienttrain.py --config clientconfigacktr.yaml
  • PPO: python clienttrain.py --config clientconfigppo.yaml
  • On-Policy HER: python clienttrain.py --config clientconfigher.yaml

Troubleshooting

If you encounter issues during the installation or running the server, consider the following troubleshooting tips:

  • Ensure Docker and nvidia-docker are properly installed and configured.
  • Verify that your GPU drivers are up to date.
  • Check the firewall settings if you are unable to connect to the server.
  • Make sure your Docker images are pulled successfully without errors.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Setting up your environment for the CARLA RL project requires a bit of effort, but the process is straightforward with the right instructions. Embrace this rewarding journey as you explore the vast realms of reinforcement learning with CARLA!

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox