Metadata-Version: 2.5
Name: gpu-rich
Version: 0.0.1
Summary: Free GPUs, driven from your terminal by your AI agent.
Project-URL: Homepage, https://github.com/mohamed2394/gpu-rich
Project-URL: Repository, https://github.com/mohamed2394/gpu-rich
Project-URL: Issues, https://github.com/mohamed2394/gpu-rich/issues
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: kaggle>=2.2
Requires-Dist: pydantic>=2.6
Requires-Dist: rich>=13
Requires-Dist: six
Requires-Dist: typer>=0.12
Provides-Extra: all
Requires-Dist: huggingface-hub>=1.0; extra == 'all'
Requires-Dist: modal>=1.6; extra == 'all'
Provides-Extra: hf
Requires-Dist: huggingface-hub>=1.0; extra == 'hf'
Provides-Extra: modal
Requires-Dist: modal>=1.6; extra == 'modal'
Description-Content-Type: text/markdown

# gpu-rich

Free GPUs, driven from your terminal by your AI agent.

`gpu-rich` sends a Python script or a Jupyter notebook to a free or cheap GPU (Kaggle, Google Colab, Modal, Hugging Face Jobs, NVIDIA Brev, or your own machine over SSH). It follows the run, and it brings the results back to your folder. A searchable index of public notebooks and fine-tuning recipes helps your coding agent find something to run.

It is made for students and people who start with machine learning and have no GPU budget.

## Status

Alpha. Not published on PyPI yet. Commands and JSON fields can still change.

| Backend | Cost | State |
|---|---|---|
| `kaggle` | free, about 30 GPU hours each week | verified in spikes |
| `colab` | free when a GPU is available; uses compute units when your account has them | verified in spikes |
| `modal` | paid, 30 USD of monthly credits on the Starter plan | verified in spikes |
| `hf` (Hugging Face Jobs) | paid | built from documentation, not yet run |
| `brev` (NVIDIA Brev) | paid | built from documentation, not yet run |
| `ssh:<host>` | your own machine | works with any host you can `ssh` to |
| `local` | this machine | for smoke tests |

The Colab backend works on Linux and macOS only, because the official Colab CLI does not support Windows.

## Install

You need Python 3.11 or newer and [uv](https://docs.astral.sh/uv/).

```bash
git clone <this repository> gpu-rich
cd gpu-rich
uv tool install --editable .
gpu-rich --version
```

`uv tool install gpu-rich` will work after the first release.

Then sign in to the platforms you want to use. `gpu-rich doctor` tells you how, for each one.

## Quickstart for a person (60 seconds)

```bash
gpu-rich doctor                      # which backends are ready, and how to fix the others
gpu-rich plan train.py               # which backend would run it, and the cost
gpu-rich run train.py --detach       # start it; prints a run id
gpu-rich wait RUN_ID --timeout 300   # wait up to 5 minutes; run it again until the run ends
gpu-rich pull RUN_ID                 # results in ./gpu-rich-runs/RUN_ID/
```

Stop a run with `gpu-rich cancel RUN_ID`.

## Quickstart for an agent

Install the skill pack into your project, then start a new agent session:

```bash
gpu-rich skills install
```

This writes `.agents/skills/gpu-rich/` (read by Codex CLI, Gemini CLI, Qwen Code and Cursor) and `.claude/skills/gpu-rich/` (read by Claude Code). Use `--global` to install it for all your projects, and `--agent NAME` for one agent only.

Then ask your agent, for example: "Fine-tune a small model on my data in data/train.csv. I have no GPU."

The agent checks the backends, prepares the job, runs it detached, waits in bounded steps, fixes failures such as out-of-memory errors, and brings the results back.

## Commands

Put `--json` before the command to get one JSON document on stdout (for agents and scripts).

| Command | What it does |
|---|---|
| `gpu-rich doctor` | Checks sign-in and quota for every backend, and says how to fix each problem. |
| `gpu-rich backends` | Lists the machines each backend offers, with price and quota. |
| `gpu-rich plan FILE` | Dry run: which backend would run the job, why, and the cost. |
| `gpu-rich run FILE` | Runs a script or a notebook. Use `--detach` to return at once. |
| `gpu-rich status [RUN]` | One run, or the recent runs. |
| `gpu-rich logs [RUN]` | The job's log. `-f` follows it, `--tail N` keeps the last lines. |
| `gpu-rich wait [RUN]` | Waits at most `--timeout` seconds, then prints the run. |
| `gpu-rich pull [RUN]` | Downloads the outputs, `result.json` and the executed notebook. |
| `gpu-rich cancel [RUN]` | Stops a run and frees the remote machine. |
| `gpu-rich search QUERY` | Searches the recipe catalog. |
| `gpu-rich show ID` | Shows one catalog entry: link, licence, needs. |
| `gpu-rich fetch ID` | Downloads a catalog entry from its upstream link. |
| `gpu-rich report [RUN]` | Shares the test result of a catalog run, when you agree. |
| `gpu-rich catalog info` / `update` | Shows or updates the local catalog index. |
| `gpu-rich skills install` / `path` / `show` | Installs or shows the agent skill pack. |

Exit codes: 0 ok, 1 the run failed, 2 wrong usage, 3 sign-in problem, 4 no backend or quota, 5 platform error.

## The job header

A script says what it needs in a [PEP 723](https://peps.python.org/pep-0723/) header. The same file still runs with plain `uv run train.py`.

```python
# /// script
# requires-python = ">=3.11"
# dependencies = ["transformers", "datasets", "peft"]
#
# [tool.gpu-rich]
# gpu = "T4"
# max_hours = 2
# outputs = ["outputs"]
# include = ["data/train.csv"]
# secrets = ["HF_TOKEN"]
# ///
```

- `outputs`: what comes back. Write your results under `outputs/`.
- `include`: extra local files to send with the job.
- `secrets`: names of environment variables. The values come from your shell, never from the file.
- `max_hours`: the job stops at this time.

Notebooks keep the same keys in their metadata under `gpu-rich`. The full format is in [skills/gpu-rich/references/job-format.md](skills/gpu-rich/references/job-format.md).

## Rules the tool follows

- It uses the official CLI or API of each platform.
- It supports one account per platform.
- It ships no tunnel, no keep-alive trick and no model serving.
- It never starts a paid backend unless you allow it.
- It never writes a token into the code it sends.

## Money safety

- Free backends come first. A paid backend runs only with `--allow-paid` or `--budget USD` on the command, or `budget_usd` in `~/.gpu-rich/config.toml`.
- `plan` shows the estimated cost before you run anything.
- Every job has a time limit (`max_hours`).
- `cancel` stops the remote machine. Check `gpu-rich status` for runs you forgot.
- Colab uses your compute units when your account has a balance. Modal, Hugging Face Jobs and Brev cost money.

## For contributors

- Tests: `uv run --group dev pytest`. Live tests against real platforms run only with `GPU_RICH_LIVE=1`.
- Adding a platform: [docs/adding-a-backend.md](docs/adding-a-backend.md).
- Release check with a real agent: [docs/agent-e2e.md](docs/agent-e2e.md).
- The design: [docs/plan.html](docs/plan.html).

## A note on the language

The tool is written in Python, because the platform SDKs are Python and ML students already have it. Once everything is stable, a rewrite in Rust is inevitable. lol.

## Licence

Apache-2.0. See [LICENSE](LICENSE). The recipe catalog links to third-party notebooks; each one keeps its own licence.
