Skip to content
Other

car-racing-ppo

PPO RL agent for CarRacing-v3

2 min readupdated

Built on the PPO algorithm, this reinforcement learning (RL) agent drives a car in the Gymnasium CarRacing-v3 simulator directly from raw screen pixels. Created by TheOnlyGoatsan using Stable-Baselines3 (CnnPolicy architecture), this release is the fourth iteration in a series of reward-function tuning experiments. Instead of relying solely on default game points, it adds penalties for driving onto the grass, drifting off the track centerline, and jerky steering, alongside a speed bonus for staying on the asphalt. It is ideal for developers and students exploring reinforcement learning and reward shaping in classic vision-based environments.

Key features

  • Higher scores: Across 100 fixed tracks, the agent averages 742 ± 31 points compared to 540 ± 34 for a baseline model trained on standard game rewards, outperforming it on 87 out of 100 tracks.
  • Pixel-based control: Takes a stack of the last 2 grayscale 64×64 frames as input and makes a steering decision every 2 frames.
  • Thoughtful reward shaping: Rewards staying near the track centerline and maintaining speed on asphalt, while penalizing grass off-tracks (-0.1) and abrupt steering changes.
  • Ready-to-use artifacts: The repository includes the model weights (final.zip), normalization stats (final_vecnormalize.pkl), and a per-track benchmark table (bench.csv).

What you can do

  • Run the pre-trained agent in Gymnasium CarRacing-v3 to evaluate its driving behavior across different tracks.
  • Use bench.csv and the custom reward formula as a baseline for your own experiments aimed at breaking the 900-point mark.

Example

To run the agent, wrap the environment with standard frame preprocessing (downscaling to 64×64, grayscale conversion, skipping 2 frames, and stacking 2 frames) and load final.zip into Stable-Baselines3. Evaluated deterministically across 100 test seeds (1000–1099), the agent hits a median score of 783 and scores 900 or higher on 15% of the tracks.

Read moreDetails
Benchmark (100 tracks): mean 742 ± 31, median 783, 15% of tracks ≥ 900 (the threshold for solving the environment is a 900 average).
Limitation: The agent lacks top speed — on 85% of tracks, it hits the 1,000-frame episode limit before completing a full lap.
Training: 4M decision steps, PPO (SB3 2.9.2) with gSDE, batch size 128, 10 epochs, linear learning rate decay from 1e-4 to 0, and 256-unit actor/critic heads (GELU).
Discuss Telegram 0 27

Will it run?

Working out the memory needs

The bot is still collecting this model's weight sizes; the estimate will appear here in a few minutes. Meanwhile you can rent a GPU with headroom.

Massed ComputeOpen Massed Compute

Run it on Massed Compute

The script downloads the model to the rented machine. How to run it is in the model card.

  1. 1. Rent a machine with a fitting GPU

    Open Massed Compute
  2. 2. Paste the script into the machine's terminal

    Connect over SSH (the Massed Compute panel shows the command) or open a terminal on the machine's desktop.

    HF_TOKEN / CIVITAI_TOKENThe script starts with token lines: paste yours between the quotes. The Hugging Face token is for gated models, the Civitai one for Civitai models.

    # TheOnlyGoatsan/car-racing-ppo
    mkdir -p ~/models
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source "$HOME/.local/bin/env"
    uv tool install "huggingface_hub[cli]"
    hf download TheOnlyGoatsan/car-racing-ppo --local-dir ~/models/car-racing-ppo
    # The model is in ~/models. How to run it is in the model card (link above).
    Add more LoRAs to car-racing-ppo
  3. 3. Use it

    The model is in ~/models. How to run it is in the model card (link above).

Stop the machine in the panel when you are done: it bills by the minute while it runs.

How to speed it up

Picked for this model type. Choose your hardware above to see what fits you exactly.

  • FlashAttention 44.0.0b40from November 18, 2026new release

    fastest exact attention on B200

    Kernels for Blackwell (beta). Exact attention without quantisation — fine for everything, LLMs included.

    How to enable: pip install flash-attn-4; vLLM and SGLang pick it up themselves.

    Earlier generations (2)
    • FlashAttention 3 — The Hopper (H100/H200) version with FP8.
    • FlashAttention 2 — The standard for RTX 30/40/50 and A100: exact attention without the memory cost of long contexts.
  • torch.compile2.15.0from October 28, 2026new release

    10–30% for free

    Compiles the model for your GPU. Slower first run, faster afterwards.

    How to enable: model = torch.compile(model); in ComfyUI the TorchCompileModel node.

Model family

New posts about versions of car-racing-ppo (quants, finetunes, LoRAs) will show up under the bell.

No known relatives of this model yet. All derivatives on Hugging Face

About the model

TheOnlyGoatsan/car-racing-ppo
Author
TheOnlyGoatsan
Category
Other
Released
Posted

On NeyroLearn

Hugging Face

270

Ask AI about this model

Answered by Gemini 4 · the chat is kept only in this tab

Comments