Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
92f0188
feat: add app-centric sdk surface with queue/api/task decorators
KAJdev Jul 1, 2026
a51a633
feat: add deploy pipeline, dev sessions, and rp cli
KAJdev Jul 1, 2026
7f0a45a
feat: bind dev templates to endpoints and verify live execution e2e
KAJdev Jul 1, 2026
f97280b
feat: add dev session refresh with file watching and storage-supporte…
KAJdev Jul 1, 2026
cce0176
feat: add pod task execution with runtime images and single-shot runner
KAJdev Jul 2, 2026
a5a3a75
feat: add custom image support for queue endpoints via bootstrap shim
KAJdev Jul 2, 2026
32dea10
feat: add queue runtime image and dev tag channel for runtime images
KAJdev Jul 2, 2026
948e49f
fix: install full package deps in runtimes test job
KAJdev Jul 2, 2026
eccea06
fix: filter lazy socket resource warnings in runner http tests
KAJdev Jul 2, 2026
f1814dd
fix: disable unraisable plugin in runtimes test job
KAJdev Jul 2, 2026
ad98a6d
feat: add api runtime server and unified bootstrap entrypoint
KAJdev Jul 2, 2026
3716886
fix: upgrade stale runpod installs in bootstrap and forward package spec
KAJdev Jul 2, 2026
62cc621
feat: probe interpreters and fetch standalone python in image shim
KAJdev Jul 2, 2026
b51a03a
fix: pretend scm version for tarball installs in bootstrap
KAJdev Jul 2, 2026
e74b604
fix: fail loudly on pythonless custom images instead of fetching an i…
KAJdev Jul 2, 2026
fe7a492
feat: vendor full runtime environment into artifacts at deploy time
KAJdev Jul 2, 2026
55dd9d4
feat: support python 3.10-3.14 with per-version gpu runtime images
KAJdev Jul 2, 2026
9538f6e
fix: use tarfile data filter for artifact extraction
KAJdev Jul 2, 2026
f2e0da5
feat: reconcile flash-bound endpoints during deploy
KAJdev Jul 2, 2026
7818704
feat: retry transient http failures and harden discovery scans
KAJdev Jul 2, 2026
dd2f0fd
fix: gpu driver injection, pool id expansion for pods, and job results
KAJdev Jul 2, 2026
c9872cb
fix: import List in tasks module
KAJdev Jul 2, 2026
4290a02
fix: fall back to RUNPOD_API_KEY env for module api key
KAJdev Jul 2, 2026
d3274ee
feat: pod log access via hapi and storage-dc pinning for gpu deploys
KAJdev Jul 2, 2026
5feb566
fix: pin cu128 torch wheels in gpu base image
KAJdev Jul 2, 2026
9c222ff
fix: pin cp310 torch stack on cu128 index
KAJdev Jul 2, 2026
a5f89f2
fix: pin cu128 torch stack via extra index across all python versions
KAJdev Jul 2, 2026
5d0f47c
fix: retry proxy 404 propagation races on task execute
KAJdev Jul 2, 2026
e847a0f
feat: pretty cli console with dev lifecycle events and deploy phases
KAJdev Jul 2, 2026
264b984
feat: unify runpod and rp entry points with grouped help panels
KAJdev Jul 3, 2026
db7d26f
feat: rich help rendering for legacy click subcommands
KAJdev Jul 3, 2026
fcd4a6a
fix: render click usage errors instead of tracebacks
KAJdev Jul 3, 2026
0be0f2f
refactor: single plain-click command tree without help panels
KAJdev Jul 3, 2026
abc0024
fix: expand gpu any to pool ids and quiet the dev loop ui
KAJdev Jul 3, 2026
b70f898
fix: async-safe awaitable driving, console links, quieter dev ui
KAJdev Jul 3, 2026
51d7ca5
feat: full console urls in deploy and dev summaries
KAJdev Jul 3, 2026
dc06b01
feat: live vendor package feed, upload bar, and upload retries in deploy
KAJdev Jul 4, 2026
1191bdf
feat: ship full module source in dev, worker monitor feed, sleeker de…
KAJdev Jul 4, 2026
142d03b
fix: tee function stdout to container logs and name interleaved dev f…
KAJdev Jul 4, 2026
6ebd36a
feat: stream worker stdout into rp dev with request-style lifecycle l…
KAJdev Jul 6, 2026
07e7fee
feat: nested dev calls, realtime log attach, refresh diffs
KAJdev Jul 6, 2026
789e471
fix: install runpod package in task runtime images
KAJdev Jul 6, 2026
8d350c1
fix: keyless dev payload construction
KAJdev Jul 6, 2026
ab4c10c
ci: disable fail-fast on runtime image matrix
KAJdev Jul 6, 2026
e1dfc83
ci: build runtime images even when gpu-base rebuild fails
KAJdev Jul 6, 2026
ff7c1b3
fix: make shipped module source inspectable for nested remote calls
KAJdev Jul 6, 2026
03c6cb3
fix: re-ship materialized module source on nested dev hops
KAJdev Jul 6, 2026
16ff3e8
feat: live api routes via source sync endpoint
KAJdev Jul 6, 2026
2d1bc64
fix: cancellable entrypoint with spinner-based session cleanup
KAJdev Jul 6, 2026
c2a25ae
feat: app and environment management, undeploy, and browser login
KAJdev Jul 6, 2026
c028747
feat: task lifecycle streaming in dev, long tasks via submit-poll
KAJdev Jul 6, 2026
a52577f
feat: task pod self-termination watchdog for abandoned clients
KAJdev Jul 6, 2026
54919bf
fix: keep task event sink attached across dev reloads
KAJdev Jul 6, 2026
4dcf329
fix: bind entrypoint exception before marshalling to the loop
KAJdev Jul 6, 2026
51f3317
feat: resolve gpu shorthand strings to device names and pools
KAJdev Jul 6, 2026
85f17db
feat: network volumes with app-wide placement solve
KAJdev Jul 7, 2026
5b46d61
feat: platform secrets with env rendering and rp secret cli
KAJdev Jul 7, 2026
5430107
feat: wrangler-style prompting for rp secret add
KAJdev Jul 7, 2026
a418531
feat: registry credentials with name resolution and rp registry cli
KAJdev Jul 7, 2026
be5d7e9
feat: platform-cached model references
KAJdev Jul 7, 2026
245e2d6
docs: apps-first readme and example suite doubling as e2e tests
KAJdev Jul 7, 2026
aefc85b
style: refine dev cli output
KAJdev Jul 8, 2026
db500aa
style: restore log stream pipe
KAJdev Jul 8, 2026
b9d5ef8
feat: add endpoint config params, rp init, rp update, and build-only …
KAJdev Jul 8, 2026
0f5ca89
docs: simplify readme
KAJdev Jul 8, 2026
d0ef53c
refactor: split showcase examples from the e2e example suite
KAJdev Jul 8, 2026
5a301bd
fix: anonymous login polling and local-python deploy default
KAJdev Jul 8, 2026
c657720
fix: retry proxy propagation 404s when polling task results
KAJdev Jul 8, 2026
3c6e9a7
fix: install resource dependencies on live api sync
KAJdev Jul 9, 2026
389dfa5
perf: cache dependency layers and skip gpu-base rebuilds for code-onl…
KAJdev Jul 9, 2026
5b5e96a
refactor: drop the config wizard and exec command group
KAJdev Jul 9, 2026
08d4ab9
refactor: standardize cli verbs to add/list/get/delete
KAJdev Jul 9, 2026
5372f90
feat: rp ssh POD_ID opens a pod terminal
KAJdev Jul 9, 2026
b3c5fd7
fix: clean errors for unknown pods and hide the ssh connect alias
KAJdev Jul 9, 2026
90ce271
fix: reject platform-cached models on task resources
KAJdev Jul 9, 2026
6c85a6c
fix: ignore fastapi testclient deprecation warning in pytest
KAJdev Jul 9, 2026
08017fb
test: cover the apps api client, targets, monitor, logs, and queue wo…
KAJdev Jul 9, 2026
c79afbc
test: cover console rendering
KAJdev Jul 9, 2026
5c423b0
test: cover deploy and dev command wiring
KAJdev Jul 9, 2026
6bbbe6b
test: cover bootstrap error surface, task lifecycle, and update inter…
KAJdev Jul 9, 2026
e795635
test: cover task runner self-termination and install helpers
KAJdev Jul 9, 2026
b031fb1
Merge remote-tracking branch 'origin/main' into feat/apps-sdk
KAJdev Jul 9, 2026
3397a3e
fix: address codeql alerts on raises, tar links, and duplicate tests
KAJdev Jul 9, 2026
1e145e8
ci: skip duplicate runtime image builds on same-repo prs
KAJdev Jul 9, 2026
43b5956
ci: publish runtime images on release instead of per pr
KAJdev Jul 9, 2026
7c3cc21
feat: job parity, streaming, and unified execution engine
KAJdev Jul 10, 2026
e5fea5e
refactor: extract apps graphql documents into api query and mutation …
KAJdev Jul 10, 2026
6ed7ca2
refactor: consolidate shared apps helpers into utils package
KAJdev Jul 10, 2026
68df2ce
feat: lazy top-level imports and curated runtime vendoring
KAJdev Jul 10, 2026
2a47e0e
feat: per-job queue options via with_options
KAJdev Jul 10, 2026
e8521ed
test: shell example runner with dev, deploy, and local modes
KAJdev Jul 10, 2026
8adc6c2
fix: address codeql and review findings across apps and runtimes
KAJdev Jul 10, 2026
3df2237
fix: address remaining apps sdk review findings
KAJdev Jul 13, 2026
ae6182d
fix: clean up apps sdk imports
KAJdev Jul 13, 2026
1ad2a48
fix: resolve apps sdk codeql findings
KAJdev Jul 13, 2026
08c8c83
refactor: consume independently released sdk runtimes
KAJdev Jul 27, 2026
938eb6f
fix: support sdk source archives in runtime launcher
KAJdev Jul 27, 2026
f8377e3
feat: group apps commands under flash
KAJdev Jul 27, 2026
3b015ab
chore: merge main into apps sdk
KAJdev Jul 27, 2026
eef269e
fix: stabilize apps production execution
KAJdev Jul 28, 2026
6a8d6ad
chore: merge main into apps sdk
KAJdev Sep 15, 2026
7a24ee5
fix: enforce apps lifecycle and resource invariants
KAJdev Sep 15, 2026
a42f5b4
fix: preserve apps capabilities across rest integration
KAJdev Sep 15, 2026
e058478
fix: keep worker-local sync calls off the event loop
KAJdev Sep 15, 2026
bb6dfcb
fix: preserve queued calls through worker cold starts
KAJdev Sep 15, 2026
b505049
fix: use sync-first queue invocation with polling handoff
KAJdev Sep 16, 2026
b83d219
fix: enforce provisioning and discovery invariants
KAJdev Sep 22, 2026
a2153c0
chore: merge main into apps sdk
KAJdev Sep 22, 2026
28a10ed
Merge branch 'main' into feat/apps-sdk
deanq Sep 29, 2026
a05e194
feat!: add explicit volume resources and execution mount bindings
KAJdev Sep 29, 2026
135d652
test: allow additive public sdk exports
KAJdev Sep 29, 2026
b2d7979
fix: provision global volumes lazily through graphql
KAJdev Sep 29, 2026
e27c810
chore: integrate upstream apps changes
KAJdev Sep 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# keep the runtime image build context to what pip install needs:
# package source, metadata, and the files setup.py/MANIFEST.in read
.git
.github
.venv
build
benchmark_results
docs
examples
job_files
scripts
tests
uv.lock
**/__pycache__
**/*.pyc
*.egg-info
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

* Apps expose `NetworkVolume` and `GlobalVolume` resources with explicit path-keyed mounts, lazy create-if-missing provisioning, and execution-bound filesystem access. Global volumes use GraphQL for lookup and creation.

## [1.12.0](https://github.com/runpod/runpod-python/compare/v1.11.0...v1.12.0) (2026-08-10)


Expand Down
127 changes: 81 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,109 @@
<div align="center">
<h1>Runpod | Python Library </h1>

[![PyPI Package](https://badge.fury.io/py/runpod.svg)](https://badge.fury.io/py/runpod)
&nbsp;
[![Downloads](https://static.pepy.tech/personalized-badge/runpod?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/runpod)
<h1>Runpod Python</h1>

[![CI | End-to-End Runpod Python Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-e2e.yml)
**Define GPU functions in Python. Run them in the cloud with one decorator.**

[![PyPI Package](https://badge.fury.io/py/runpod.svg)](https://badge.fury.io/py/runpod)
[![Downloads](https://static.pepy.tech/personalized-badge/runpod?period=total&units=international_system&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/runpod)
[![CI | Unit Tests](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-pytests.yml)
&nbsp;
[![CI | CodeQL](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml/badge.svg)](https://github.com/runpod/runpod-python/actions/workflows/CI-codeql.yml)
[![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)

[Documentation](https://docs.runpod.io) • [Examples](examples/apps) • [Discord](https://discord.gg/pJ3P2DbUUq)

</div>

Welcome to the official Python library for Runpod API &amp; SDK.
## Installation

## Table of Contents
```bash
pip install runpod # or: uv add runpod
rp login # authenticate once
```

- [Table of Contents](#table-of-contents)
- [💻 | Installation](#--installation)
- [⚡ | Serverless Worker (SDK)](#--serverless-worker-sdk)
- [Quick Start](#quick-start)
- [Local Test Worker](#local-test-worker)
- [📚 | REST API v2 Wrapper](#--rest-api-v2-wrapper)
- [Endpoints](#endpoints)
- [GPU Cloud (Pods)](#gpu-cloud-pods)
- [📁 | Directory](#--directory)
- [🤝 | Community and Contributing](#--community-and-contributing)
Requires Python 3.10+. Installing the package also installs the `rp` CLI.

## 💻 | Installation
## Example

### Install from PyPI (Stable Release)
```python
import runpod
from runpod import App, Model, NetworkVolume, Secret

```bash
# Install with pip
pip install runpod
app = App("inference")

# Install with uv (faster alternative)
uv add runpod
```
models = NetworkVolume("models", size=100)
llama = Model("meta-llama/Llama-3.1-8B-Instruct")


# an autoscaling job queue on cloud H100s: weights pre-cached,
# dependencies vendored at deploy time, scale-to-zero when idle
@app.queue(
gpu="H100",
workers=(0, 3),
dependencies=["vllm"],
mounts={"/runpod-volume": models},
model=llama,
env={"HF_TOKEN": Secret("hf-token")},
)
def chat(prompt: str):
import vllm

llm = vllm.LLM(model=str(llama.path)) # weights already on disk
return llm.generate(prompt)

### Install from GitHub (Latest Changes)

To get the latest changes that haven't been released to PyPI yet:
# one ephemeral pod per call: provisions, runs to completion, terminates
@app.task(gpu="H100", gpu_count=2, mounts={"/models": models})
def finetune(steps: int = 1000):
...
return {"loss": final_loss}


@runpod.local_entrypoint
def main():
print(chat.remote("why is the sky blue?")) # blocks for the result
job = finetune.spawn(steps=500) # fire and forget -> Job
```

```bash
# Install latest development version from main branch with pip
pip install git+https://github.com/runpod/runpod-python.git
rp flash dev main.py # live dev session: edit, re-run, logs stream back
rp flash deploy # deploy production endpoints
```

Functions keep their Python identity: `chat.remote(...)` runs in the cloud, `await chat.remote.aio(...)` is the async form, `chat.local(...)` runs in-process. See [`examples/apps`](examples/apps) for runnable examples and [docs.runpod.io](https://docs.runpod.io) for the full guide.

Queue `.remote()` calls request a synchronous result and poll the same job if the server's wait window expires. Fast results need no client-side polling. Dev sessions use a short sync window to keep worker logs responsive. Use `.spawn()` for an asynchronous job handle. A transport failure before receiving a job ID raises an error without resubmitting the work.

## Storage

# Install with uv
uv add git+https://github.com/runpod/runpod-python.git
`NetworkVolume(name_or_id, size=50, datacenter=None, create=True)` references
datacenter-local storage. Apps resolve names and choose a datacenter compatible
with every resource sharing the volume. `GlobalVolume(name_or_id, create=True)`
references global storage without a datacenter constraint. Both inherit from
the abstract `Volume` base, resolve by name or ID, and create missing storage
when provisioning remote compute. Set `create=False` to require existing storage.
Global-volume lookup and creation use GraphQL; network volumes use REST.

# Install a specific branch
pip install git+https://github.com/runpod/runpod-python.git@branch-name
Declare attachments with `mounts={"/path": volume}`. Tasks support one network
and one global volume at distinct, non-overlapping paths. Queue and API resources
support one volume at `/runpod-volume`; global storage requires a GPU endpoint.

# Install a specific tag/release
pip install git+https://github.com/runpod/runpod-python.git@v1.0.0
Inside worker code, `volume.path` returns the configured mount path. The runtime
binds declared references and resolved IDs before importing user code. Access
raises if the volume is unmounted or has multiple bindings. Evaluate `.path`
inside remote functions, not during local module discovery. Calling `.local()`
does not mount remote storage on the client machine.

# Install in editable mode for development
## Contributing

Pull requests and issues are welcome — see the [contributing guide](CONTRIBUTING.md) to get started.

```bash
git clone https://github.com/runpod/runpod-python.git
cd runpod-python
pip install -e .
make setup
make test
```

*Python 3.10 or higher is required to use the latest version of this package.*

## ⚡ | Serverless Worker (SDK)

This python package can also be used to create a serverless worker that can be deployed to Runpod as a custom endpoint API.
Expand Down Expand Up @@ -347,12 +386,8 @@ runpod.terminate_pod(pod["id"])
└── tests # Package tests
```

## 🤝 | Community and Contributing

We welcome both pull requests and issues on [GitHub](https://github.com/runpod/runpod-python). Bug fixes and new features are encouraged, but please read our [contributing guide](CONTRIBUTING.md) first.

<div align="center">

<a target="_blank" href="https://discord.gg/pJ3P2DbUUq">![Discord Banner 2](https://discordapp.com/api/guilds/912829806415085598/widget.png?style=banner2)</a>
<a target="_blank" href="https://discord.gg/pJ3P2DbUUq">![Discord](https://discordapp.com/api/guilds/912829806415085598/widget.png?style=banner2)</a>

</div>
62 changes: 39 additions & 23 deletions docs/cli/references/command_line_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,58 @@ Note: This CLI is not the same as runpodctl and provides a different set of feat

```bash
# Auth
runpod config

runpod ssh list-keys
runpod ssh add-key

runpod pod list
runpod pod create
runpod pod connect

runpod exec python file.py
rp login

# Flash apps
rp flash init my-app
rp flash dev main.py
rp flash deploy
rp flash app list
rp flash env list --app my-app
rp flash undeploy --app my-app

# SSH
rp ssh add # add a key to your account
rp ssh list # list account keys
rp ssh POD_ID # open a terminal on a pod

# Pods
rp pod list
rp pod create
rp pod connect POD_ID
```

## Overview

```bash
runpod --help
rp --help
```

### Configure
### Authenticate

```bash
$ runpod config
Profile [default]:
Runpod API Key [None]: YOUR_RUNPOD_API_KEY
rp login # browser approval
rp login --api-key YOUR_KEY # store a key directly
rp login --profile staging # save browser credentials in a named profile
```

### Launch Pod
Credentials are stored in `~/.runpod/config.toml`.
Use `--profile NAME` with either login method to update only that profile; the default is `default`.

### Flash apps

```bash
runpod launch --help
runpod launch pod --template-file template.yaml
rp flash init my-app # scaffold a project
rp flash dev main.py # run a live development session
rp flash deploy # deploy the current project
rp flash app list # list deployed apps
rp flash env list --app my-app # list an app's environments
rp flash undeploy --app my-app # delete an environment's endpoints
```

### Launch Endpoint
App discovery imports modules synchronously. Keep blocking work inside an
entrypoint or a resource function; interrupt discovery if an import blocks.

```bash
runpod launch endpoint --help
runpod launch endpoint --template-file template.yaml
```
On Ctrl-C, a dev session waits for its running local entrypoint to finish before
deleting endpoints. Blocking entrypoint code can delay shutdown. Cleanup failures
exit with an error and report the endpoint IDs that still need deletion.
20 changes: 10 additions & 10 deletions docs/cli/start_here.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# [BETA] | Runpod Python CLI Reference
# Runpod CLI Reference

Note: This CLI is not the same as runpodctl and provides a different set of features.

## Getting Started

![runpod --help](demos/help.gif)
![rp --help](demos/help.gif)

### Configure
### Authenticate

![runpod config](demos/config.gif)
Store your Runpod API key by running `rp login` (browser approval) or `rp login --api-key YOUR_KEY`. Credentials are stored in `~/.runpod/config.toml`.

Store your Runpod API key by running `runpod config`. Optionally you can also call the command with your API key `runpod config YOUR_API_KEY` or include the `--profile` to save multiple keys (stored under "default" profile is not specified) Credentials are stored in `~/.runpod/config.toml`.
Pass `--profile staging` with either login method to update a named credential profile without changing the others. The default profile is `default`.

![runpod ssh add-key](demos/ssh.gif)
### SSH

Add a SSH key to you account by running `runpod ssh add-key`. To specify and existing key pass in `--key` or `--key-file` to use a file. Keys are stored in `~/.runpod/ssh/`. If no key is specified a new one will be generated and stored.
Add an SSH key to your account by running `rp ssh add`. To use an existing key pass `--key` or `--key-file`. Keys are stored in `~/.runpod/ssh/`. If no key is specified a new one is generated and stored.

## Runpod Project
Once a key is added, open a terminal on any pod with `rp ssh <pod_id>` (or the equivalent `rp pod connect <pod_id>`).

A "project" is the start of a serverless worker. To get started call `runpod project new`, you will be asked a few questions about the project you are creating, a project folder will be created. You can now navigate into your repo and run `runpod project start`.
## Apps

Once you are finished developing you can run `runpod project deploy` to deploy your project and create an endpoint.
An app is a collection of Python functions that run on Runpod. Scaffold one with `rp flash init`, iterate on it live with `rp flash dev main.py`, and ship it with `rp flash deploy`. See the [README](../../README.md) for the full workflow.
25 changes: 25 additions & 0 deletions examples/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# app examples

each file is a self-contained app showing one way to use the sdk.
run any of them live with `rp flash dev`:

```bash
rp flash dev examples/apps/hello_world.py
```

| example | shows |
|---|---|
| `hello_world` | one queue function, one `.remote()` call |
| `streaming` | generator functions, `.stream()` chunks, `job.stream()` |
| `gpu_inference` | gpu selection, dependencies, a cuda benchmark |
| `web_service` | `@app.api` class with routes and per-worker state |
| `train_and_eval` | gpu tasks sharing checkpoints through a volume |

edit a file while the session is running, then press enter to re-run —
workers pick up the new code automatically. the exhaustive
feature-by-feature suite lives in [`tests/e2e/examples`](../../tests/e2e/examples).

`await task.spawn.aio(...)` returns a task job that owns its pod.
`await job.wait(timeout=...)` terminates that pod when waiting finishes, including
timeout, task failure, or cancellation. use `await job.cancel()` to abandon a
spawned task explicitly. a failed termination retains `job.pod_id` for cleanup.
43 changes: 43 additions & 0 deletions examples/apps/gpu_inference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Run a function on a GPU.

Ask for hardware by name — "4090", "H100", "B200" all work, as do
pool ids like GpuGroup.ADA_24 and exact device names. Dependencies
listed on the decorator are ready before your function runs, so the
worker needs no custom image.

rp flash dev examples/apps/gpu_inference.py
"""

import runpod

app = runpod.App("gpu-demo")


@app.queue(gpu="4090", dependencies=["numpy"])
def matmul_benchmark(size: int = 4096):
import time

import torch

device = torch.cuda.get_device_name(0)
print(f"running on {device}")

a = torch.randn(size, size, device="cuda")
b = torch.randn(size, size, device="cuda")

torch.cuda.synchronize()
start = time.time()
for _ in range(10):
_ = a @ b
torch.cuda.synchronize()
elapsed = time.time() - start

tflops = 10 * 2 * size**3 / elapsed / 1e12
print(f"{size}x{size} matmul: {tflops:.1f} TFLOPS")
return {"device": device, "tflops": round(tflops, 1)}


@runpod.local_entrypoint
def main():
result = matmul_benchmark.remote()
print("benchmark:", result)
Loading
Loading