CLI 命令参考¶
gpuctl CLI 与 kubectl 对标,但语义更贴近算法工程师的使用习惯。
命令概览¶
| 命令 | 说明 |
|---|---|
create |
从 YAML 创建资源(任务、资源池、配额) |
apply |
应用配置(创建或更新,等价于先删后建) |
get |
查询资源列表 |
describe |
查看资源详情 |
delete |
删除资源 |
logs |
查看任务日志 |
label |
管理节点标签 |
create¶
从 YAML 文件创建资源。
| 选项 | 说明 | 是否必填 |
|---|---|---|
-f, --file |
YAML 文件路径(可多次指定) | 是 |
-n, --namespace |
命名空间(默认:default) |
否 |
--json |
以 JSON 格式输出 | 否 |
示例:
# 提交单个任务
gpuctl create -f training-job.yaml
# 批量提交多个任务
gpuctl create -f task1.yaml -f task2.yaml
# 指定命名空间
gpuctl create -f job.yaml -n team-alice
# JSON 格式输出
gpuctl create -f job.yaml --json
apply¶
应用资源配置(先删除旧资源,再创建新资源)。
| 选项 | 说明 | 是否必填 |
|---|---|---|
-f, --file |
YAML 文件路径(可多次指定) | 是 |
-n, --namespace |
命名空间(默认:default) |
否 |
--json |
以 JSON 格式输出 | 否 |
示例:
get¶
查询资源列表。支持多种资源类型和过滤条件。
get jobs¶
| 选项 | 说明 |
|---|---|
-n, --namespace |
指定命名空间(不指定则查询所有) |
--pool |
按资源池过滤 |
--kind |
按任务类型过滤:training / inference / notebook / compute |
--pods |
显示 Pod 级别信息(而非 Deployment/StatefulSet 级别) |
--json |
JSON 格式输出 |
输出列说明:
| 列 | 含义 |
|---|---|
| JOB ID | Pod 名称(含 K8s 自动生成的 hash 后缀) |
| NAME | YAML 中的 job.name |
| NAMESPACE | 所在命名空间 |
| KIND | 任务类型 |
| STATUS | Pod 运行状态 |
| READY | 就绪/总容器数(如 1/1) |
| NODE | 调度到的节点 |
| IP | Pod IP |
| AGE | 创建至今的时长 |
示例:
gpuctl get jobs
gpuctl get jobs -n team-alice
gpuctl get jobs --pool training-pool
gpuctl get jobs --kind training
gpuctl get jobs --pods
get pools¶
示例:
get nodes¶
| 选项 | 说明 |
|---|---|
--pool |
按资源池过滤 |
--gpu-type |
按 GPU 型号过滤 |
示例:
get labels¶
示例:
get quotas¶
示例:
get ns / namespaces¶
describe¶
查看资源详细信息。
describe job¶
输出内容:
- 基本信息:Name、Kind、Resource Type、Namespace、Status、Age、Priority、Pool
- 资源配置:CPU、Memory、GPU
- 原始 YAML:从 K8s 资源反映射回的 gpuctl YAML 配置
- Events:最近 10 条 K8s 事件
- Access Methods(仅 inference / notebook / compute):Pod IP 和 NodePort 访问地址
示例:
describe pool¶
示例:
describe node¶
示例:
describe quota / ns / namespace¶
gpuctl describe quota <namespace_name> [--json]
gpuctl describe ns <namespace_name> [--json]
gpuctl describe namespace <namespace_name> [--json]
示例:
delete¶
删除资源。
通过 YAML 文件删除¶
示例:
delete job¶
示例:
gpuctl delete job my-training-job
gpuctl delete job my-training-job -n team-alice
gpuctl delete job my-training-job --force
delete quota¶
示例:
delete ns / namespace¶
gpuctl delete ns <namespace_name> [--force] [--json]
gpuctl delete namespace <namespace_name> [--force] [--json]
示例:
delete pool¶
示例:
删除任务的行为
删除任务时,平台会同时删除:
- K8s 主资源(Job / Deployment / StatefulSet)
- 关联的 NodePort Service(training 任务无 Service)
- K8s 控制器会自动级联删除关联的 Pod
logs¶
获取任务日志。
| 选项 | 说明 |
|---|---|
<job_name> |
任务名称 |
-n, --namespace |
命名空间(默认:default) |
-f, --follow |
实时跟踪日志(类似 tail -f) |
--json |
JSON 格式输出 |
示例:
# 查看最近日志(默认最后 100 行)
gpuctl logs my-training-job
# 实时跟踪
gpuctl logs my-training-job -f
# 指定命名空间
gpuctl logs my-training-job -n team-alice -f
label¶
管理节点标签。
标签键规范
gpuctl 管理的标签键必须以 runwhere.ai/ 开头,避免与其他系统冲突。
| 选项 | 说明 |
|---|---|
<node_name> |
节点名称(可指定多个) |
<label> |
key=value 格式(添加)或 key 格式(删除时使用) |
--delete |
删除标签 |
--overwrite |
覆盖已有同键标签 |
示例:
# 给单个节点添加 GPU 型号标签
gpuctl label node-1 runwhere.ai/gpu-type=A100-100G
# 给多个节点添加标签(注意:node_name 在命令中的位置)
gpuctl label node-1 node-2 runwhere.ai/gpu-type=A100-100G
# 覆盖已有标签
gpuctl label node-1 runwhere.ai/gpu-type=A10-24G --overwrite
# 删除标签
gpuctl label node-1 runwhere.ai/gpu-type --delete
# 绑定资源池
gpuctl label node-1 runwhere.ai/pool=training-pool
全局选项¶
| 选项 | 说明 |
|---|---|
--help |
显示帮助信息 |
--json |
以 JSON 格式输出(大多数命令支持) |
完整工作流示例¶
训练任务生命周期¶
# 1. 查看可用资源
gpuctl get nodes
gpuctl get pools
# 2. 提交训练任务
gpuctl create -f training-job.yaml -n team-alice
# 3. 监控状态
gpuctl get jobs -n team-alice
# 4. 实时查看日志
gpuctl logs my-training -n team-alice -f
# 5. 查看详细信息
gpuctl describe job my-training -n team-alice
# 6. 任务完成后清理
gpuctl delete job my-training -n team-alice