runwhere CLI
任务 YAML
用 YAML 声明任务类型、镜像、命令、GPU、工作目录、模型和 checkpoint。
runwhere sync 和 runwhere submit 都以 YAML 任务文件为入口。YAML 描述任务要跑什么、使用什么环境、需要多少 GPU、哪些文件需要同步,以及模型和 checkpoint 放在哪里。
全局字段
kind: Training | Inference | Notebook
version: v1
job:
name: <string>
description: <string>| 字段 | 必填 | 说明 |
|---|---|---|
kind | 建议填写 | 任务类型:Training、Inference、Notebook。未填时按 Training 处理。 |
version | 建议填写 | YAML schema 版本,当前使用 v1。 |
job.name | 是 | 任务名,用于列表、日志、停止、删除和恢复。 |
job.description | 否 | 任务描述,便于控制台和排障识别。 |
最小训练任务
version: v1
kind: Training
job:
name: llama-finetune
environment:
image: pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
command: "python train.py --config configs/sft.yaml"
resources:
gpuNum: 1
gpuType: a100-80g
storage:
workdirs:
- path: "."
checkpoint:
path: "checkpoints/"environment
environment:
image: <string>
conda: <string>
requirements: <string>
command: <string | list>
args:
- <string>
env:
KEY: value| 字段 | 说明 |
|---|---|
image | 容器镜像。可以使用 RunWhere 镜像,也可以使用自己的镜像。 |
conda | Conda 环境声明。不能和 requirements 同时指定。 |
requirements | pip 依赖文件路径。不能和 conda 同时指定。 |
command | 启动命令。支持字符串或 argv 数组。Notebook 可不填。 |
args | 命令参数,适合把镜像入口和参数分开维护。 |
env | 任务运行时环境变量。 |
镜像选择建议(以下均为公开镜像,可直接拉取):
| 场景 | 示例 | 说明 |
|---|---|---|
| PyTorch 训练 | pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime | 常规训练和微调,自带 conda。 |
| vLLM 推理 | vllm/vllm-openai:v0.12.0 | 部署 OpenAI-compatible 推理服务。 |
| Notebook | jupyter/tensorflow-notebook:latest | 交互式开发;轻量场景可用 jupyter/minimal-notebook:latest。 |
| 需要编译 CUDA 扩展 | pytorch/pytorch:2.4.1-cuda12.1-cudnn9-devel | 包含 nvcc 和开发库。 |
| 自定义镜像 | registry.example.com/team/image:tag | 团队已有镜像。 |
resources
resources:
gpuNum: 1
gpuType: a100-80g
gpuSkuKey: aliyun/cn-hangzhou/cn-hangzhou-i/on_demand/ecs.gn7e| 字段 | 说明 |
|---|---|
gpuNum | GPU 数量。 |
gpuType | GPU 型号,例如 t4、a100-80g、h100-80g、l40s。可用型号见 runwhere price summary。 |
gpuSkuKey | 具体资源 Offer,从 runwhere price list 或 runwhere price recommend 输出复制。 |
gpuType 和 gpuSkuKey 至少填一个。只填 gpuType 时,CLI 会自动比价并选择合适 Offer;填了 gpuSkuKey 时,以 gpuSkuKey 为准。
如果 gpuType 无法解析到可用 Offer(型号拼写错误,或比价数据暂不可用),submit 会直接失败并给出明确提示:
✗ 无法为 gpuType='t4' 自动选机(未知型号或比价服务暂不可达)
→ 检查 GPU 型号拼写,或在 YAML 填 resources.gpuSkuKey 指定具体 Offer(runwhere price list 查 SKU KEY)storage
storage:
workdirs:
- path: "."
models:
- source: huggingface://Qwen/Qwen2.5-7B-Instruct
path: /models/qwen
checkpoint:
path: checkpoints/| 字段 | 说明 |
|---|---|
workdirs | 要同步和挂载的工作目录。 |
models | 需要提前下载或挂载的模型。 |
checkpoint | checkpoint 路径,用于恢复和故障重试。 |
storage.models[].source 支持 huggingface://org/model 和 modelscope://org/model 两种声明,国内网络环境建议优先 ModelScope。模型准备发生在同步和任务准备阶段,避免每个任务重复下载。
声明 storage.checkpoint.path 后,训练代码应写入该目录下的 checkpoint。长时间训练建议阅读 Checkpoint 最佳实践,区分高频暂存和持久恢复路径。
常用模板
Training:单机训练
适合单卡或单机多卡微调。
kind: Training
version: v1
job:
name: llama3-lora
environment:
image: pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
command: python finetune.py --model_name=/models/llama3-8b --lora_r=16
env:
WANDB_PROJECT: llama3-lora
resources:
gpuNum: 1
gpuType: a100-80g
storage:
workdirs:
- path: "."
models:
- source: huggingface://meta-llama/Llama-3-8B
path: /models/llama3-8b
checkpoint:
path: checkpoints/llama3-loraTraining:requirements.txt
kind: Training
version: v1
job:
name: lora-ft
environment:
image: pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
requirements: requirements.txt
command: python train.py
resources:
gpuNum: 1
gpuType: a100-80g
storage:
workdirs:
- path: "."
checkpoint:
path: checkpoints/lora-ftTraining:conda 环境
kind: Training
version: v1
job:
name: qwen-sft
environment:
image: pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime
conda: myenv
command: python train.py
resources:
gpuNum: 8
gpuType: a100-80g
storage:
workdirs:
- path: "."
models:
- source: huggingface://Qwen/Qwen2.5-7B
path: /models/qwen2.5-7bInference
version: v1
kind: Inference
job:
name: qwen-api
environment:
image: vllm/vllm-openai:v0.12.0
command:
- python
- -m
- vllm.entrypoints.openai.api_server
env:
MODEL: Qwen/Qwen2.5-7B-Instruct
resources:
gpuNum: 1
gpuType: a10
storage:
models:
- source: "huggingface://Qwen/Qwen2.5-7B-Instruct"
path: "/models/qwen"Notebook
version: v1
kind: Notebook
job:
name: research-notebook
environment:
image: jupyter/tensorflow-notebook:latest
resources:
gpuNum: 1
gpuType: a100-80g
storage:
workdirs:
- path: "."提交后,用 runwhere logs <name> -f 查看服务就绪事件和访问 URL。
默认值速查
| 字段 | 默认行为 | 何时填写 |
|---|---|---|
kind | 按 Training 处理 | 建议显式填写。 |
job.description | 无 | 需要在控制台或排障信息中标注任务意图时。 |
environment.conda | 无 | 需要复现已有 conda 环境时。 |
environment.requirements | 无 | 需要安装额外 pip 依赖时。 |
environment.args | 无 | Inference 或复杂启动参数推荐拆开。 |
storage.checkpoint | 不启用 | 训练时间较长或需要恢复能力时。 |
校验规则
- 顶层必须是 YAML mapping。
job.name必须填写。environment.conda和environment.requirements不能同时填写。resources.gpuType和resources.gpuSkuKey至少填写一个。- 生产任务建议先
runwhere price recommend -f <yaml>,再把选定的gpuSkuKey写回 YAML。