Installation
Gym-Khana is a pure Python package.
Tip
We recommend installing inside a virtual environment to avoid dependency conflicts.
Using pip (recommended)
virtualenv gym_env
source gym_env/bin/activate
git clone --recurse-submodules https://github.com/TeoIlie/Gym-Khana.git
cd Gym-Khana
pip install -e .
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:
Your virtual environment is selected as the Python interpreter (
Ctrl+Shift+P→ Python: Select Interpreter).acados_templateis installed into that virtual environment withpip install -eas shown above (this lets acados use the virtualenv’scasadi).