An open-source GPU broker for fleets of coding agents.
ogpu lets several coding agents (Claude Code, Codex, OpenCode) hill-climb kernels on one shared H200 without stepping on each other's timings. Every GPU job takes an exclusive lock, identical submissions are deduplicated by content hash, and every run lands in a local SQLite cost ledger. Machines come from RunPod, Modal, a host you already have, or your own provider.
Status: alpha. Built for the Open Kernel Challenge, where agents ran 745 jobs across 21 kernel tracks on one shared H200. RunPod is the most exercised provider. Modal is newer; see Known limitations.
When several agents share one GPU, three things go wrong:
- Timings collide. Two benchmarks on the same GPU slow each other down, and both agents chase noise.
- Work gets paid for twice. Agents resubmit the same candidate, often at the same time.
- Nobody knows what was spent or tried. Results live in scattered terminal logs.
| Problem | What ogpu does |
|---|---|
| Overlapping timings | Exclusive lock. GPU jobs queue on an exclusive flock on the machine and run one at a time. CPU-only jobs (compiles, ptxas gates) run in parallel, pinned to reserved cores at the lowest priority so they don't disturb the timed job. Each job runs from its own snapshot of the code. |
| Duplicate work | Content-hash dedupe. The key is a hash of the synced files, command, image, provider and GPU types. With --cache or cache = true, a finished identical run returns its result at no cost, and an identical job already in flight is joined rather than started again. Infrastructure failures are never reused. |
| Unknown spend | SQLite cost ledger. ~/.ogpu/ledger.db records every run (agent, command, status, failure class, wall time, cost, parsed metrics) and every machine session's uptime and hourly price. ogpu ledger and ogpu cost read it, and so can any SQLite client. |
Also included:
- No paying for idle. An on-machine reaper stops the machine after a configurable idle period. Disks and compiled caches persist for the next job. Modal jobs bill per second and have nothing to stop.
- Budget cap. Beyond the daily limit, new jobs are refused. Modal jobs count toward spend while still running.
- Multi-fidelity runs. Send
--fidelity correctnessjobs to a cheaper pool so the expensive GPU only times candidates that already work.ogpu sweepruns a whole tournament this way. - GPU fallback. List GPU types and tiers in the order you prefer. ogpu moves down the list on capacity errors and replaces hosts that fail a real GPU allocation.
- Built for agents. One-line JSON results, classified failures with error excerpts, async
submit/wait, meaningful exit codes, and a shared record of what has been tried.
Requires Python 3.11+ and uv. RunPod and SSH hosts also need rsync and an SSH key.
git clone https://github.com/Sudhendra/openGPU.git
cd openGPU
# RunPod or SSH hosts only
uv tool install .
# With Modal support (installs the `modal` CLI too)
uv tool install '.[modal]' --with-executables-from modalThen authenticate with your provider:
export RUNPOD_API_KEY=... # RunPod
modal token new # Modalogpu config # creates ~/.ogpu/config.toml
ogpu gpus H100 # GPU ids and prices for your provider
cd path/to/your/project
ogpu run --gpu -- python3 train.py # sync, run under the GPU lock, stream the log
ogpu cost # spend, GPU-busy time, spend per agentogpu top opens a live dashboard of machines, queues and spend.
# Run
ogpu run --gpu -m "lr 3e-4" -- python3 train.py --steps 200 # exclusive GPU lock, queued
ogpu run --cpu -- python3 compile_check.py # no lock, runs immediately
ogpu run --gpu --fidelity correctness -- python3 test_kernel.py # cheaper pool, if configured
ogpu run --gpu --with ../shared --timeout 900 --cache -- ... # extra dirs, runtime cap, reuse results
# Queue now, collect later
ogpu submit --gpu -m "hypothesis" -- python3 bench.py a.py b.py
ogpu wait <id> [<id> ...]
# Tournament: correctness on the cheap pool, quick timing, then full timing for finalists
ogpu sweep --bench "python3 bench.py {files}" --best best.py cand_*.py
# One command per line, in parallel
ogpu fanout cmds.txt --provider modal --gpu L4
# Results
ogpu ledger [--track T] [--best | --failed] [--json]
ogpu show <id>
ogpu logs <id> [-f]
ogpu cancel <id>
# Machines and money
ogpu up [--pool P] [--retry MIN]
ogpu down [--terminate]
ogpu status
ogpu cost
ogpu gpus [FILTER] [--provider P]With --json, every run ends with one line:
{"id": "1030-164825-d47177", "status": "done", "failure": null, "error": null, "exit_code": 0,
"wall_s": 212.4, "cost_usd": 0.31, "metrics": {"score": 1.083, "loss": 0.412}, "note": "lr 3e-4",
"pool": "timing", "log_path": "~/.ogpu/logs/1030-164825-d47177.log", "cached_from": null}| Field | Meaning |
|---|---|
metrics |
Print OGPU_METRIC name=value from your script. score (higher is better) ranks ogpu ledger --best. |
failure |
null, or one of compile_error, import_error, correctness_fail, oom, cuda_error, timeout, hang, runtime_error, launch_error, lost, cancelled. |
error |
The relevant excerpt from the log. |
cached_from |
The earlier run this result came from, if the cache was used. |
Exit codes: the job's own code, 2 if the daily budget cap was reached, 3 if the job ran but correctness checks failed.
Output files: anything your command writes to out/ is copied back to <project>/output/ogpu/<id>/.
| Provider | Type | Auth | Notes |
|---|---|---|---|
runpod |
Machine | RUNPOD_API_KEY |
Tiers COMMUNITY and SECURE. Filters hosts by min_cuda. |
modal |
Serverless | modal token new |
One container per job. GPU ids include H200, H100, A100-80GB, L40S, L4, T4. |
ssh |
Machine | SSH key | A host you already have. Set host, port, user, cost_per_hr and stop_cmd under [providers.ssh]. |
Set provider at the top level and override it per pool. For example, timing on RunPod and correctness on Modal:
provider = "runpod"
gpu_type_ids = ["NVIDIA H100 80GB HBM3"]
[pools.correctness]
provider = "modal"
gpu_type_ids = ["L4"]Modal bills for CPU and memory as well as the GPU. Containers default to 2 cores and 8 GiB; raise them only if a job needs more:
[providers.modal]
cpu = 2
memory_gb = 8Subclass ogpu.providers.Provider and implement get, find, create, resume, stop and terminate. providers/ssh.py is the smallest example. Then point the config at it:
provider = "mycloud"
[providers.mycloud]
module = "my_pkg.mycloud:MyCloud" # or an `ogpu.providers` entry point named "mycloud"
region = "us-east" # other keys are passed to the provider as `opts`Settings live in ~/.ogpu/config.toml. Secrets come from the environment, never this file. Unknown keys are rejected, so a typo can't silently fall back to a default.
| Key | Default | Description |
|---|---|---|
provider |
runpod |
runpod, modal, ssh, or your own |
gpu_type_ids |
provider default | Provider-native GPU ids, tried in order |
cloud_types |
provider default | Provider tiers, tried in order |
image |
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel |
Any image with python3 |
idle_minutes |
10 |
Idle time before a machine stops itself |
budget_usd |
25 |
Daily spend cap |
cache |
false |
Reuse identical runs (--cache/--no-cache per run) |
min_cuda |
12.4 |
Only use hosts whose driver supports this CUDA version |
profile |
"" |
Named preset, e.g. okc |
volume_gb |
50 |
Persistent volume at /workspace |
container_disk_gb |
50 |
Container disk |
auto_up |
true |
Bring machines up on demand |
quiet_timing |
true |
Keep CPU jobs off the timing cores |
[pools.correctness] |
none | Any of the keys above, for --fidelity correctness jobs |
Environment variables: OGPU_AGENT (label in the ledger), OGPU_HOME (default ~/.ogpu), OGPU_NO_NOTIFY, OGPU_MODAL_<GPU>_HR (override a Modal GPU's hourly rate).
With cache = true or --cache, a run with the same synced files, command, image, provider and GPU types returns the earlier result, and identical in-flight jobs are joined rather than run twice. Passes and failures caused by the code itself are reused. Launch errors, timeouts, hangs, out-of-memory and CUDA errors always re-run.
The ledger is a plain SQLite file, so you can ask it anything:
# spend and runs per agent
sqlite3 ~/.ogpu/ledger.db "select agent, count(*), round(sum(cost_usd), 2) from runs group by agent order by 3 desc"
# failures by class
sqlite3 ~/.ogpu/ledger.db "select failure, count(*) from runs where failure is not null group by failure"runs has one row per job. sessions has one row per machine session, with its uptime and hourly price.
profile = "okc" presets ogpu for the Open Kernel Challenge: the judge image on an H200 timing pool, an H100 correctness pool, min_cuda = 13.0, and parsing of the OKC bench output into metrics. Anything you set in the config still takes precedence.
./scripts/install-skill.sh # installs the `ogpu` skill for Claude Code, Codex and OpenCode- Skill:
skills/ogpu/SKILL.mdteaches agents the commands, the result format and an experiment loop. - Project rule: paste
agents/OGPU.mdinto your project'sAGENTS.mdorCLAUDE.md. - Guard hook (Claude Code): use
scripts/hooks/guard_gpu.pyas aPreToolUsehook to block rawssh/scpto machines,runpodctlandmodal run.
your machine GPU machine
┌──────────────────────┐ rsync + ssh ┌─────────────────────────────────────────────┐
│ ogpu CLI │ ──────────────▶ │ /workspace/src/<project> latest sync │
│ ledger.db (SQLite) │ │ /workspace/.ogpu/runs/<job>/ job snapshot │
│ ogpu top │ ◀── poll/logs ──│ jobrun.py GPU lock, timeouts, watchdog │
│ │ │ reaper.py idle → stop via provider │
└──────────────────────┘ └─────────────────────────────────────────────┘
ogpu runchecks the budget and, if enabled, the cache, then makes sure the pool's machine is up.- It syncs your project and submits the job. The runner snapshots the code, takes the GPU lock and runs detached, so SSH drops and Ctrl-C don't kill it.
- The CLI polls the log, pulls back
out/, parses metrics, classifies failures and writes the ledger. - The reaper stops the machine once it has been idle long enough.
On Modal there is no machine to manage: each job gets its own container, and results come back when it finishes.
- A Modal job is tied to the local
modal runprocess, so it stops if your laptop sleeps or that process is killed. ogpu logs -fcan't follow a running Modal job, andogpu waithas no deadline for Modal jobs.- Modal timeouts are reported as
runtime_errorrather thantimeout. - Modal cost estimates don't include container start-up time, so they run slightly low.
- Projects with the same directory name collide on a shared machine.
- API keys are sent in
Authorizationheaders, never URLs. - Machines accept SSH with your public key only. Host keys are pinned per machine in
~/.ogpu/known_hosts/. If a provider restarts a machine outside ogpu and its key changes, delete that machine's file there to reconnect. ~/.ogpuand the SSH control-socket directory are private (0700).- Jobs on a shared machine run as root. The lock, guard hook and skill are for cooperating agents; they are not a sandbox, so don't share a machine with code you don't trust.
- Custom providers are Python code that runs on your machine. Only load ones you trust.
uv sync
uv run pytest -q| Path | Contents |
|---|---|
src/ogpu/ |
CLI, job runner, ledger, dashboard |
src/ogpu/providers/ |
RunPod, Modal, SSH and the plugin interface |
src/ogpu/remote/ |
Code that runs on the GPU machine (standard library only) |
src/ogpu/okc.py |
The Open Kernel Challenge profile |
skills/, agents/, scripts/ |
Agent integrations |
tests/ |
Test suite, including the on-machine runner exercised locally |
Apache License 2.0. See LICENSE.