Skip to content

ucbdrive/pyTORCS

Repository files navigation

PyTORCS

Python interface for The Open Racing Car Simulator (TORCS)

Configure graphics driver (Important!)

  1. Go to "Software & Updates" in Ubuntu 16.04 system settings, check "source code" in "Ubuntu Software" tab.
  2. Download NVIDIA-Linux-x86_64-415.25.run (for other versions, visit NVIDIA's official website).
  3. Blacklist Nouveau.
    sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nouveau.conf"
    sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nouveau.conf"
    sudo update-initramfs -u
    sudo reboot
  4. Install graphics driver with --no-opengl-files flag.
    sudo chmod a+x NVIDIA-Linux-x86_64-415.25.run
    sudo service lightdm stop
    sudo bash NVIDIA-Linux-x86_64-415.25.run --no-opengl-files

Install TORCS and PyTORCS

Note that in order to install torcs on your computer system, you may need to install CUDA driver without opengl libs. The gym-TORCS environment has only been tested on Ubuntu 16.04 environment, and currently it does not support windows or macOSX environment.

git clone https://github.com/ucbdrive/pyTORCS
cd pyTORCS
bash install.sh

Usage of PyTORCS

import numpy as np
import gym
import py_TORCS

env = gym.make('TORCS-v0')
obs, info = env.reset()
obs, reward, terminal, info = env.step(np.array([1.0, 0.0]))

Have fun!