Runpod Flash AI 负载开发部署
flash
使用 runpod-flash SDK 和 CLI 在 Runpod 无服务器 GPU 或 CPU 上开发和部署 AI 工作负载。
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-15
- Stars
- ★ 635
- Forks
- 91
01 前言 Front Matter
- name
- flash
- description
- Develop and deploy AI workloads with the runpod-flash SDK and CLI on Runpod serverless GPUs or CPUs.
- user-invocable
- true
02 资源文件 3
- 参考文档README.md2.5 KB
- 参考文档references/analyst-prompt.md6.1 KB
- 参考文档references/gatherer-prompt.md5.2 KB
03 SKILL.md 正文
Runpod Flash
Write code locally, test with flash run (dev server at localhost:8888), and flash automatically provisions and deploys to remote GPUs/CPUs in the cloud. Endpoint handles everything.
Setup
pip install runpod-flash # requires Python >=3.10
# auth option 1: browser-based login (saves token locally)
flash login
# auth option 2: API key via environment variable
export RUNPOD_API_KEY=your_key
flash init my-project # scaffold a new project in ./my-project
CLI
flash run # start local dev server at localhost:8888
flash run --auto-provision # same, but pre-provision endpoints (no cold start)
flash build # package artifact for deployment (500MB limit)
flash build --exclude pkg1,pkg2 # exclude packages from build
flash deploy # build + deploy (auto-selects env if only one)
flash deploy --env staging # build + deploy to "staging" environment
flash deploy --app my-app --env prod # deploy a specific app to an environment
flash deploy --preview # build + launch local preview in Docker
flash env list # list deployment environments
flash env create staging # create "staging" environment
flash env get staging # show environment details + resources
flash env delete staging # delete environment + tear down resources
flash undeploy list # list all active endpoints
flash undeploy my-endpoint # remove a specific endpoint
Endpoint: Three Modes
Mode 1: Your Code (Queue-Based Decorator)
One function = one endpoint with its own workers.
from runpod_flash import Endpoint, GpuGroup
@Endpoint(name="my-worker", gpu=GpuGroup.AMPERE_80, workers=5, dependencies=["torch"])
async def compute(data):
import torch # MUST import inside function (cloudpickle)
return {"sum": torch.tensor(data, device="cuda").sum().item()}
result = await compute([1, 2, 3])
Mode 2: Your Code (Load-Balanced Routes)
Multiple HTTP routes share one pool of workers.
from runpod_flash import Endpoint, GpuGroup
api = Endpoint(name="my-api", gpu=GpuGroup.ADA_24, workers=(1, 5), dependencies=["torch"])
@api.post("/predict")
async def predict(data: list[float]):
import torch
return {"result": torch.tensor(data, device="cuda").sum().item()}
@api.get("/health")
async def health():
return {"status": "ok"}
Mode 3: External Image (Client)
Deploy a pre-built Docker image and call it via HTTP.
from runpod_flash import Endpoint, GpuGroup, PodTemplate
server = Endpoint(
name="my-server",
image="my-org/my-image:latest",
gpu=GpuGroup.AMPERE_80,
workers=1,
env={"HF_TOKEN": "xxx"},
template=PodTemplate(containerDiskInGb=100),
)
# LB-style
result = await server.post("/v1/completions", {"prompt": "hello"})
models = await server.get("/v1/models")
# QB-style
job = await server.run({"prompt": "hello"})
await job.wait()
print(job.output)
Connect to an existing endpoint by ID (no provisioning):
ep = Endpoint(id="abc123")
job = await ep.runsync({"input": "hello"})
print(job.output)
How Mode Is Determined
| Parameters | Mode |
|---|---|
name= only |
Decorator (your code) |
image= set |
Client (deploys image, then HTTP calls) |
id= set |
Client (connects to existing, no provisioning) |
Endpoint Constructor
Endpoint(
name="endpoint-name", # required (unless id= set)
id=None, # connect to existing endpoint
gpu=GpuGroup.AMPERE_80, # single GPU type (default: ANY)
gpu=[GpuGroup.ADA_24, GpuGroup.AMPERE_80], # or list for auto-select by supply
cpu=CpuInstanceType.CPU5C_4_8, # CPU type (mutually exclusive with gpu)
workers=5, # shorthand for (0, 5)
workers=(1, 5), # explicit (min, max)
idle_timeout=60, # seconds before scale-down (default: 60)
dependencies=["torch"], # pip packages for remote exec
system_dependencies=["ffmpeg"], # apt-get packages
image="org/image:tag", # pre-built Docker image (client mode)
env={"KEY": "val"}, # environment variables
volume=NetworkVolume(...), # persistent storage
gpu_count=1, # GPUs per worker
template=PodTemplate(containerDiskInGb=100),
flashboot=True, # fast cold starts
execution_timeout_ms=0, # max execution time (0 = unlimited)
)
gpu=andcpu=are mutually exclusiveworkers=5means(0, 5). Default is(0, 1)idle_timeoutdefault is 60 secondsflashboot=True(default) -- enables fast cold starts via snapshot restoregpu_count-- GPUs per worker (default 1), use >1 for multi-GPU models
NetworkVolume
NetworkVolume(name="my-vol", size=100) # size in GB, default 100
PodTemplate
PodTemplate(
containerDiskInGb=64, # container disk size (default 64)
dockerArgs="", # extra docker arguments
ports="", # exposed ports
startScript="", # script to run on start
)
EndpointJob
Returned by ep.run() and ep.runsync() in client mode.
job = await ep.run({"data": [1, 2, 3]})
await job.wait(timeout=120) # poll until done
print(job.id, job.output, job.error, job.done)
await job.cancel()
GPU Types (GpuGroup)
| Enum | GPU | VRAM |
|---|---|---|
ANY |
any | varies |
AMPERE_16 |
RTX A4000 | 16GB |
AMPERE_24 |
RTX A5000/L4 | 24GB |
AMPERE_48 |
A40/A6000 | 48GB |
AMPERE_80 |
A100 | 80GB |
ADA_24 |
RTX 4090 | 24GB |
ADA_32_PRO |
RTX 5090 | 32GB |
ADA_48_PRO |
RTX 6000 Ada | 48GB |
ADA_80_PRO |
H100 PCIe (80GB) / H100 HBM3 (80GB) / H100 NVL (94GB) | 80GB+ |
HOPPER_141 |
H200 | 141GB |
CPU Types (CpuInstanceType)
| Enum | vCPU | RAM | Max Disk | Type |
|---|---|---|---|---|
CPU3G_1_4 |
1 | 4GB | 10GB | General |
CPU3G_2_8 |
2 | 8GB | 20GB | General |
CPU3G_4_16 |
4 | 16GB | 40GB | General |
CPU3G_8_32 |
8 | 32GB | 80GB | General |
CPU3C_1_2 |
1 | 2GB | 10GB | Compute |
CPU3C_2_4 |
2 | 4GB | 20GB | Compute |
CPU3C_4_8 |
4 | 8GB | 40GB | Compute |
CPU3C_8_16 |
8 | 16GB | 80GB | Compute |
CPU5C_1_2 |
1 | 2GB | 15GB | Compute (5th gen) |
CPU5C_2_4 |
2 | 4GB | 30GB | Compute (5th gen) |
CPU5C_4_8 |
4 | 8GB | 60GB | Compute (5th gen) |
CPU5C_8_16 |
8 | 16GB | 120GB | Compute (5th gen) |
from runpod_flash import Endpoint, CpuInstanceType
@Endpoint(name="cpu-work", cpu=CpuInstanceType.CPU5C_4_8, workers=5, dependencies=["pandas"])
async def process(data):
import pandas as pd
return pd.DataFrame(data).describe().to_dict()
Common Patterns
CPU + GPU Pipeline
from runpod_flash import Endpoint, GpuGroup, CpuInstanceType
@Endpoint(name="preprocess", cpu=CpuInstanceType.CPU5C_4_8, workers=5, dependencies=["pandas"])
async def preprocess(raw):
import pandas as pd
return pd.DataFrame(raw).to_dict("records")
@Endpoint(name="infer", gpu=GpuGroup.AMPERE_80, workers=5, dependencies=["torch"])
async def infer(clean):
import torch
t = torch.tensor([[v for v in r.values()] for r in clean], device="cuda")
return {"predictions": t.mean(dim=1).tolist()}
async def pipeline(data):
return await infer(await preprocess(data))
Parallel Execution
import asyncio
results = await asyncio.gather(compute(a), compute(b), compute(c))
Gotchas
- Imports outside function -- most common error. Everything inside the decorated function.
- Forgetting await -- all decorated functions and client methods need
await. - Missing dependencies -- must list in
dependencies=[]. - gpu/cpu are exclusive -- pick one per Endpoint.
- idle_timeout is seconds -- default 60s, not minutes.
- 10MB payload limit -- pass URLs, not large objects.
- Client vs decorator --
image=/id== client. Otherwise = decorator. - Auto GPU switching requires workers >= 5 -- pass a list of GPU types (e.g.
gpu=[GpuGroup.ADA_24, GpuGroup.AMPERE_80]) and setworkers=5or higher. The platform only auto-switches GPU types based on supply when max workers is at least 5. runsynctimeout is 60s -- cold starts can exceed 60s. Useep.runsync(data, timeout=120)for first requests or useep.run()+job.wait()instead.
04 同仓库更多 Skills
humanizer
Rewrite AI-sounding text so it reads like the writer without changing what it says. Use when editing or reviewing prose for AI tells: not-X-but-Y contrasts, one-line closers, staged openers, forced triads, dashes everywhere, inflated claims, sales language, stock AI words, bold labels, or filler.
NodeTool可视化AI工作流构建
nodetool
使用 NodeTool MCP 服务器构建、验证、运行和调试可视化 AI 工作流,并处理资产、集合和任务。当用户提及 NodeTool,或要求在其 NodeTool 服务器上创建工作流图、节点或运行媒体生成时使用。
Wan 2.6 视频提示词编写
wan-2-6-prompting
为阿里的 Wan 2.6 视频模型编写提示词——文生视频采用全局风格描述行加上按时间用括号标记的分镜,图生视频只描述随时间变化的内容。涵盖各服务商的镜头模式切换、提示词预算、负面提示词、运动强度措辞、音频输入和提示词扩展。当模型 ID 指定 Wan 2.6 视频路由(alibaba/wan-2.6/text-to-video、alibaba/wan-2.6/image-to-video、wan-video/wan-2.6-t2v、wan-video/wan-2.6-i2v、wan-video/wan2.6-i2v-flash)用于 generate_video、animate_image 或 TextToVideo 节点时使用。不适用于 Wan 2.5 或 2.7,也不适用于 Wan 2.6 图像路由。
可复用视频工作流搭建
video-workflow
构建可复用的 NodeTool 视频工作流,用于批量处理或重复输入。若只需制作单个成品,请使用 storyboard(分镜)技能。
参考视频镜头结构复刻
video-clone
分析参考视频,并在 NodeTool 中使用新产品或新演员重现其镜头结构。
多场景视频音频连续性处理
video-audio-continuity
让由生成视频剪辑而成的多场景作品中的声音保持连续——为什么每个场景各生成一段片段会在每处边界硬切音频、何时改为把所有场景写入同一次生成、能在服务商版权过滤下保留下来的声音设计词汇,以及如何检查返回内容的时长、宽高比和混音效果。当作品包含多个场景且视频模型会自行生成音频(Seedance 2、Veo 3、MiniMax H3、Kling 2.6 及更高版本),或剪辑的声音在镜头切换处中断时使用。