gerkone / pyTORCS-docker

Docker-based, gym-like torcs environment with vision.
17 stars 3 forks source link
docker gym gym-environment racing reinforcement-learning-environments torcs torcs-env torcs-rl

pyTORCS + Docker

PPO in lagunaseca

Features

Installation

This project is designed to run on a Linux system, ideally with an Nvidia GPU.

The Docker image allows for easier porting on multiple systems.

1 install docker -> guide

Verify docker works

sudo docker run hello-world

2 docker postinstall -> guide

Additionally you can set up docker to run without sudo

sudo groupadd docker
sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

Eventually configure docker to start on boot.

sudo systemctl enable docker

3 install nvidia-docker -> guide.

The NVIDIA Container Toolkit allows users to build and run GPU accelerated Docker containers. Nvidia-docker essentially exposes the GPU to the containers to use: https://github.com/NVIDIA/nvidia-docker

4a pull the torcs image

docker pull gerkone/torcs

4b build the torcs image yourself

docker build -t <your image name> torcs/

5 install python requirements

pip install -r requirements.txt

(optional) install konsole

Konsole is already shipped with every KDE installation.

On Ubuntu

sudo apt-get install konsole

On Arch/Manjaro

sudo pacman -S konsole

Host installation

It is possible to install TORCS on the host without using docker. To do so follow this guide guide. Pay attention to the configuration section.

Usage

To run the example you can use the script pytorcs.py.

python pytorcs.py

This will start the TORCS container, open a new window with the game and start running the agent.

You can change some settings and options by editing the simulation.yaml file.

For more details on how the action and state space work check this.

For more details on the parameters and on how to use your test code and custom algorithm check this.

You can run pytorcs in a detached shell with your emulator of choice with

python pytorcs.py --console <konsole|terminator|xterm|gnome-terminal...>

If you want to run the TORCS container manually you can use

nvidia-docker run --ipc=host -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=unix$DISPLAY -p 3001:3001/udp -it --rm -d gerkone/torcs

Environment

More info on the environment and its usages can be found on here.

Troubleshooting and known issues

References

TORCS

This torcs is a modified version of 1.3.7 taken from here.

I made the following changes to the source:

scr_server

The torcs server used is _scrserver by Daniele Loiacono et al.

The Python-side client is an extended version of snakeoil3.

TF2RL

An adapted version of the tf2rl library by keiohta is included with the agents.