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, shutil for staging and local result copies, rsync for remote result downloads, 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; relative sync.local_path and results.local_path resolve against it. If no config is found, the runner uses defaults with the current directory as the root.
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 the YAML
backendsetting (defaultskypilot), unless--backendoverrides it. - Stages code: copies
sync.local_pathinto a staging directory, applying exclude patterns (see Sync below). - Provisions:
- skypilot: uses the optional Python SDK to launch a
sky.Taskwith the configured resources, environment, setup, staged workdir, and idle autostop. SkyPilot uploads the workdir to~/sky_workdir.upwaits for the readiness job to finish and attempts teardown if launch fails. - local: creates
~/.gpu-runner/clusters/<name>/workand stages code there.
- skypilot: uses the optional Python SDK to launch a
- Saves state with
remote_workdir(~/sky_workdirfor SkyPilot, local path for local).
- Loads saved state and fails if none is found.
- Runs
setup(if configured) before eachruncommand, including when using--command. If setup fails, the run command is skipped. On SkyPilot, setup also runs duringup.- skypilot: submits setup and run as separate
sky.execjobs and follows their logs until they exit. - local: runs subprocesses in the staged workdir with the configured environment merged into the local environment.
- skypilot: submits setup and run as separate
- Copies results back:
- skypilot: downloads
<cluster>:<results.remote_path>to<results.local_path>with rsync over SSH; ifresults.cloud_storageis set, also runs an upload command on the cluster. - local: copies from
<cluster-dir>/results, falling back to<cluster-dir>/work/resultsif the first path doesn't exist.results.remote_pathandresults.cloud_storagedo not apply to this backend.
- skypilot: downloads
- Logs and returns the exit code. SkyPilot saves that code in state; result transfer failures reported by the SkyPilot backend do not replace it.
- skypilot: calls
sky.downand waits for teardown. - local: deletes the cluster directory.
- Clears the state file after the teardown call returns, even if the backend reports failure.
Uses a fresh cluster name with a random suffix. If up succeeds, it runs the experiment, then attempts teardown unless the run failed and keep_cluster_on_failure: true.
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 remove the literal .git exclusion. Matching uses fnmatch against both the full relative path and each path component; full .gitignore and .dockerignore syntax is not supported.
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-centr
73A2
al1-a
use_spot: false
setup: | # before each run; also during SkyPilot up
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)
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 the optional SkyPilot SDK in the same Python environment as gpurun,
# with the extras needed for your provider:
pip install 'skypilot[huggingface,runpod]>=0.14.3'Requires Python ≥3.10. The local backend does not require SkyPilot. For the SkyPilot backend, configure at least one provider (sky check) and have rsync and SSH available for result downloads.
gpu-runner and gpurun are interchangeable.
# 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 saved state (does not query the provider)
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.
- Exclusions default to skipping
.git, venvs, caches so uploads stay small. - Cloud result uploads are best-effort and require
gsutilorawson the cluster.
uv sync --group dev
uv run pytest -qTests live in tests/ and cover config loading, staging and exclusions, state persistence, and the SkyPilot backend with a mocked SDK. They do not provision cloud resources.