logo

Installation

Gym-Khana is a pure Python package.

Tip

We recommend installing inside a virtual environment to avoid dependency conflicts.

Using poetry

poetry install
source $(poetry env info -p)/bin/activate  # or prefix commands with `poetry run`

Using Docker

A Dockerfile is provided with GUI support via nvidia-docker (NVIDIA GPU required):

docker build -t gymkhana -f Dockerfile .
docker run --gpus all -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix gymkhana

Additional dependencies

Note

MPC controllers require dependencies that cannot be installed via pip alone. These are optional — the core environment and RL training work without them.

For the reference MPC implementation see the ForzaETH race_stack.

acados (build from source) — see the official installation docs and Python interface docs:

# Clone and build (~/software is only an example install directory)
git clone https://github.com/acados/acados.git --recurse-submodules ~/software/acados
cd ~/software/acados && mkdir build && cd build
cmake -DACADOS_WITH_QPOASES=ON ..
make install -j$(nproc)

# Environment variables (add to shell profile)
export ACADOS_SOURCE_DIR=~/software/acados
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/software/acados/lib

Install the acados_template Python interface inside your virtual environment:

pip install -e ~/software/acados/interfaces/acados_template

Tip

VSCode debugging: If your IDE reports ModuleNotFoundError for acados_template or casadi when debugging, ensure that:

  1. Your virtual environment is selected as the Python interpreter (Ctrl+Shift+PPython: Select Interpreter).

  2. acados_template is installed into that virtual environment with pip install -e as shown above (this lets acados use the virtualenv’s casadi).