RunWhereRunWhere Docs
runwhere CLI

任务 YAML

用 YAML 声明任务类型、镜像、命令、GPU、工作目录、模型和 checkpoint。

runwhere syncrunwhere submit 都以 YAML 任务文件为入口。YAML 描述任务要跑什么、使用什么环境、需要多少 GPU、哪些文件需要同步,以及模型和 checkpoint 放在哪里。

任务 YAMLkind · versionjobname · descriptionenvironmentimage · command · 依赖resourcesgpuNum · gpuType / gpuSkuKeystorageworkdirs · checkpoint
一份任务 YAML 由四组字段构成

全局字段

kind: Training | Inference | Notebook
version: v1

job:
  name: <string>
  description: <string>
字段必填说明
kind建议填写任务类型:TrainingInferenceNotebook。未填时按 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 镜像,也可以使用自己的镜像。
condaConda 环境声明。不能和 requirements 同时指定。
requirementspip 依赖文件路径。不能和 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 推理服务。
Notebookjupyter/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
字段说明
gpuNumGPU 数量。
gpuTypeGPU 型号,例如 t4a100-80gh100-80gl40s。可用型号见 runwhere price summary
gpuSkuKey具体资源 Offer,从 runwhere price listrunwhere price recommend 输出复制。

gpuTypegpuSkuKey 至少填一个。只填 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需要提前下载或挂载的模型。
checkpointcheckpoint 路径,用于恢复和故障重试。

storage.models[].source 支持 huggingface://org/modelmodelscope://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-lora

Training: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-ft

Training: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-7b

Inference

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.argsInference 或复杂启动参数推荐拆开。
storage.checkpoint不启用训练时间较长或需要恢复能力时。

校验规则

  • 顶层必须是 YAML mapping。
  • job.name 必须填写。
  • environment.condaenvironment.requirements 不能同时填写。
  • resources.gpuTyperesources.gpuSkuKey 至少填写一个。
  • 生产任务建议先 runwhere price recommend -f <yaml>,再把选定的 gpuSkuKey 写回 YAML。

On this page