gpu-runner is a CLI for running ML experiments on ephemeral GPU clusters. You write a small YAML config in your project, then either manage the cluster lifecycle in three steps (up, run, down) or do everything in one shot (submit).
It reuses existing tools rather than reimplementing them: SkyPilot for provisioning/teardown across clouds, rsync/scp + shutil for code and result transfer, and .dockerignore/.gitignore for exclusion rules.
When you run any command, the CLI looks for gpu-runner.yaml / gpu-runner.yml (or dotfile variants) starting in the current directory and walking up to the filesystem root. You can override with -c path/to/file.yaml. The config is parsed into an ExperimentConfig (name, backend, resources, setup, run command, env, sync, results, etc.). The directory containing the config becomes the project root; all relative paths (sync.local_path, results.local_path) resolve against it.
Cluster state lives in <root>/.gpu-runner/state.json and contains: cluster name, backend, remote workdir, local staged code path, last run exit code. This is what lets up, run, and down be separate commands — each invocation reloads state instead of re-provisioning.
- Resolves the cluster name from
config.name(sanitized). - Selects a backend from
config.provider_backend(skypilotorlocal). - Stages code: copies
sync.local_pathinto a staging directory, applying exclude patterns (see Sync below). - Provisions:
- skypilot: writes a temporary SkyPilot task YAML (resources, envs, setup, a no-op run, workdir = staged dir, idle autostop) and runs
sky launch -c <cluster> -y <yaml>. SkyPilot uploads the workdir to~/sky_workdiron the cluster. - local: creates
~/.gpu-runner/clusters/<name>/workand stages code there.
- skypilot: writes a temporary SkyPilot task YAML (resources, envs, setup, a no-op run, workdir = staged dir, idle autostop) and runs
- Saves state with
remote_workdir(~/sky_workdirfor SkyPilot, local path for local).
- Loads state; fails fast if no cluster is up.
- Runs
config.setup(if any) thenconfig.run(or--commandoverride):- skypilot:
sky exec <cluster> "cd ~/sky_workdir && <cmd>". - local: subprocess in the staged workdir with merged env.
- skypilot:
- Records exit code in state.
- Copies results back:
- skypilot:
scp -r <cluster>:<results.remote_path> <results.local_path>; ifresults.cloud_storageis set, also runs an upload command on the cluster. - local: copies from the cluster's results dir into
results.local_path.
- skypilot:
- Prints exit code.
- skypilot:
sky down <cluster> -y. - local: deletes the cluster directory.
- Clears state file.
Runs up → run → down. If the run fails and keep_cluster_on_failure: true, it skips teardown so you can debug. Otherwise it always tears down, even on failure, to avoid leaking cost.
Code is staged with shutil.copytree using an ignore function. Exclusion patterns come from:
sync.excludesin config,- Files listed in
sync.ignore_files(default.dockerignore,.gitignore) — each non-comment, non-blank line is treated as a pattern, - Built-in defaults:
.gpu-runner,.git,__pycache__,*.pyc,node_modules,.venv,venv.
Set sync.include_git: true to keep .git. Matching uses fnmatch against both the full relative path and each path component.
For SkyPilot, the staged directory is passed as workdir, so SkyPilot itself handles the upload to ~/sky_workdir. For the local backend, staging is the cluster.
name: my-experiment # cluster/experiment name
backend: skypilot # skypilot | local
resources:
accelerators: "A100:1" # SkyPilot accelerator spec
cpus: 4
memory: "16"
disk_size: 100
image_id: "..." # optional VM image
cloud: gcp # optional; auto-select if omitted
region: us-central1
zone: us-central1-a
use_spot: false
setup: | # runs once at provision time
pip install -r requirements.txt
run: python train.py # default command for `run`
env: # injected into remote env
WANDB_API_KEY: "..."
sync:
local_path: . # source dir (relative to config)
remote_path: ~/work
excludes: ["*.log", "data/"]
ignore_files: [".dockerignore", ".gitignore"]
include_git: false
results:
remote_path: ~/results # where the experiment writes results
local_path: ./results # where to copy them locally
cloud_storage: gs://bucket/prefix # optional remote upload target
idle_minutes_to_autostop: 30 # SkyPilot autostop
keep_cluster_on_failure: falsepip install -e .
# Install SkyPilot separately, with the extras needed for your provider:
pip install 'skypilot[huggingface,runpod]>=0.14.3'Requires Python ≥3.10. For the SkyPilot backend you also need SkyPilot configured for at least one cloud (sky check).
# three-step
gpu-runner up
gpu-runner run # or: gpu-runner run --command "python eval.py"
gpu-runner down
# one-shot
gpu-runner submit
# inspect
gpu-runner status
# override backend/config
gpu-runner --backend local submit
gpu-runner -c experiments/exp.yaml up- skypilot: provisions real ephemeral clusters via SkyPilot (GCP/AWS/Azure/Lambda/…). Multi-cloud, spot support, autostop.
- local: runs in a local directory under
~/.gpu-runner/clusters/. Useful for developing and testing experiment code without a cluster.
- State is file-based, so commands are composable in scripts and CI.
submittears down even on failure unlesskeep_cluster_on_failureis set, preventing cost leaks.- Exclusions default to skipping
.git, venvs, caches so uploads stay small. - Results copy is best-effort for cloud storage (uses
gsutil/aws s3on the cluster). - Exit codes propagate from the remote run command.
uv sync --group dev
uv run pytest -qTests live in tests/ and cover sync staging/exclusion logic and config loading.