通过CLI使用百舸服务
使用命令行工具操作百舸与用户在百舸操作具有相同的权限控制,AK/SK所属用户需要在百舸控制台获得对应的操作权限(如资源池、队列、训练任务的开发权限、管理员权限)才能对资源池、队列、训练任务进行管理操作
通用语法和参数
1$ aihc [资源] <command> [flags] [options]
- 全局通用参数 --help/-h:所有命令可以通过此参数获得帮助信息,查看使用说明
- 列表页通用参数 --order :列表页接口支持排序参数,可选值asc, desc,默认值desc
--orderBy:设置排序字段,默认值createTime
--page:支持分页的接口可以指定页数,默认值1
-s, --size:分页大小,默认值100
p/n/q:带有翻页的命令,输p/n/q可以实现翻页或退出(上一页:p;下一页:n;退出:q)
查看参数说明
在输入任何命令之后添加 -h ,即可查看对应命令的参数说明,例如 aihc job list -h
1# 获取任务列表命令的参数说明
2$ aihc job list -h
3列出所有的训练任务。
4
5Usage:
6 aihc job list [flags]
7
8Aliases:
9 list, ls
10
11Flags:
12 -h, --help help for list
13 -n, --name string 任务名称关键字
14 --order string 排序方式(asc/desc) (default "desc")
15 -o, --order-by string 排序字段 (default "createdAt")
16 --page int 页码 (default 1)
17 -p, --pool string 资源池ID
18 -q, --queue string 队列ID
19 --size int 每页显示数量 (default 100)
20
21Global Flags:
22 -C, --config string Global configuration file. (default "/Users/luyuchao/.aihc/config")
资源池相关操作
获取资源池列表
1$ aihc pool list [flags]
2 Flags:
3 -h, --help help for list
4 -w, --keyWord string keyWord
5 -k, --keyWordType string keyWordType (default "resourcePoolName")
6 -l, --limit int Number of resource pools to return (default 100)
7 --offset int Offset of the first resource pool to return
8 --order string Sort order (asc, desc) (default "ASC")
9 -o, --orderBy string Order by field (name, createTime) (default "createTime")
10 -p, --pageNo int Page number (default 1)
11 -s, --pageSize int Page size (default 50)
12 -t, --resourcePoolType string (common-自运维资源池,dedicatedV2-全托管资源池) (default "common")
- 命令示例
1# 当存在多页数据时,可以输入 p/n 进行上一页/下一页翻页;输入 q 退出当前命令
2$ aihc pool list
3
4Page 1 of 1 (Total items: 4)
5
6NAME ID STATUS NODE_COUNT GPU_COUNT CREATED_AT
7---------------------------------------------------------------------------------------------------------------------------------------
8jun-gateway cce-mj***fzk running 1/2 4/8 2025-03-06 06:41:33
9lingang-hpas-runtime-02 cce-zq***i4dy running 1/1 0/0 2025-02-10 13:44:45
10lingang-hpas-runtime cce-4k***u9u running 4/4 0/0 2025-02-10 12:19:42
11workflow-lijipeng cce-5u***vro running 4/4 0/0 2025-01-21 11:22:09
12
13Navigation:
14 q - Quit
15
16Enter command (p/n/q):
获取资源池详情
1$ aihc pool get [flags]
2-h, --help help for get
3-p, --pool string Resource pool ID 指定资源池ID
- 命令示例(获取指定资源池详情)
1$ aihc pool get -p cce-mjtzk
2
3resourcePool:
4 metadata:
5 createdAt: "2025-03-06T06:41:33Z"
6 id: cce-mjtzk
7 name: jun-gateway
8 updatedAt: "2025-03-06T08:34:59Z"
9 spec:
10 associatedCpromIds: []
11 associatedPfsId: ""
12 createdBy: unpeng
13 description: ""
14 forbidDelete: true
15 k8sVersion: 1.24.4
16 region: bj
17 status:
18 gpuCount:
19 total: 8
20 used: 4
21 gpuDetail:
22 - gpudescriptor: baidu.com/l20_cgpu
23 total: 8
24 used: 4
25 nodeCount:
26 total: 2
27 used: 1
28 phase: running
- 命令示例(获取默认资源池详情)
1# 当设置了默认资源池时,可以省略 -p/--pool 参数,工具直接使用默认资源池作为 -p/--pool参数
2$ aihc pool get
3
4resourcePool:
5 metadata:
6 createdAt: "2023-09-17T15:48:04Z"
7 id: cce-4h***1m
8 name: IAT-Regression-pei
9 updatedAt: "2025-02-11T08:21:50Z"
10 spec:
11 associatedCpromIds:
12 - cprom-xm1***3k3s7
13 associatedPfsId: pfs-p***jz
14 createdBy: ""
15 description: ""
16 forbidDelete: true
17 k8sVersion: 1.20.8
18 region: bj
19 status:
20 gpuCount:
21 total: 16
22 used: 1
23 gpuDetail:
24 - gpudescriptor: baidu.com/xpu
25 total: 8
26 used: 0
27 - gpudescriptor: baidu.com/a800_80g_cgpu
28 total: 8
29 used: 1
30 nodeCount:
31 total: 3
32 used: 1
33 phase: running
队列相关操作
获取队列列表
1aihc queue list/ls [flags]
2Flags:
3 -h, --help help for list
4 -k, --keyword string Keyword
5 -t, --keywordtype string Keyword type
6 -r, --order string Sort order
7 -o, --orderby string Sort field (default "dec")
8 -n, --pagenumber int Page number (default 3)
9 -s, --pagesize int Page size (default 100)
10 -p, --pool string Resource pool ID
- 命令示例(获取指定资源池的队列列表)
1 $ aihc queue list -p cce-mjtzk
2
3name state queueType reclaimable disableOversell createdTime
4openapi-regular--dtea Open Elastic True False 2025-03-16T19:47:18Z
563a9f0ea7bb98050796b649e85481845 Open Elastic True False 2025-03-14T03:47:13Z
6default Open Elastic True False 2025-03-14T03:47:12Z
- 命令示例(获取默认资源池队的列列表)
1# 当设置了默认资源池时,可以省略 -p/--pool 参数,工具直接使用默认资源池作为 -p/--pool参数
2$ aihc queue list
3
4name state queueType reclaimable disableOversell createdTime
5openapi-regular--dtea Open Elastic True False 2025-03-16T19:47:18Z
663a9f0ea7bb98050796b649e85481845 Open Elastic True False 2025-03-14T03:47:13Z
7default Open Elastic True False 2025-03-14T03:47:12Z
获取队列详情
1$ aihc queue get queueID [flags]
2-h, --help help for get
3-p, --pool string Resource pool ID 指定资源池ID
- 命令示例
1$ aihc queue get 63a9f0ea7bb98050796b649e85481845 -p cce-2k9sw0cjaihc
2
3$ aihc queue get 63a9f0ea7bb98050796b649e85481845
任务相关操作
获取任务列表
1$ aihc job list/ls [flags]
2
3 Flags:
4 -h, --help help for list
5 -n, --name string 任务名称关键字
6 --order string 排序方式(asc/desc) (default "desc")
7 -o, --order-by string 排序字段 (default "createdAt")
8 --page int 页码 (default 1)
9 -p, --pool string 资源池ID
10 -q, --queue string 队列ID
11 --size int 每页显示数量 (default 100)
- 命令示例(指定全托管资源池)
查询托管资源池下任务需指定 -p aihc-serverless
1$ aihc job list -p aihc-serverless
2
3Page 1 of 1 (Total items: 6)
4
5
6NAME JOB_ID STATUS CREATED_AT
7aihc-createjob-test pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 Created 2025-02-17T07:59:35Z
8qwen2-vl-test-4-copy1 pytorchjob-a53c413c-8e96-416b-8d6a-bc3e1b16a406 Succeeded 2025-01-01T13:22:19Z
9qwen2-vl-test-4 pytorchjob-0389039d-aae5-4601-8e9e-fb230867baa4 ManualTermination 2025-01-01T12:00:52Z
10qwen2-vl-test-one-copy1 pytorchjob-c9ac1567-4306-4085-8432-5305f4dc600f ManualTermination 2024-12-31T15:22:26Z
11qwen2-vl-test-2 pytorchjob-5c6c22c4-2c8d-49e7-8c2e-46e5fc2caa24 ManualTermination 2024-12-31T14:26:05Z
12qwen2-vl-test-one pytorchjob-ba8b2830-06c6-462f-aaf7-8c2513733482 Succeeded 2024-12-31T14:18:47Z
13
14Navigation:
15q - Quit
16
17Enter command (p/n/q):
- 命令示例(指定自运维资源池)
1$ aihc job list -p cce-2k0cj
2
3Page 1 of 1 (Total items: 6)
4
5
6NAME JOB_ID STATUS CREATED_AT
7aihc-createjob-test pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 Created 2025-02-17T07:59:35Z
8qwen2-vl-test-4-copy1 pytorchjob-a53c413c-8e96-416b-8d6a-bc3e1b16a406 Succeeded 2025-01-01T13:22:19Z
9qwen2-vl-test-4 pytorchjob-0389039d-aae5-4601-8e9e-fb230867baa4 ManualTermination 2025-01-01T12:00:52Z
10qwen2-vl-test-one-copy1 pytorchjob-c9ac1567-4306-4085-8432-5305f4dc600f ManualTermination 2024-12-31T15:22:26Z
11qwen2-vl-test-2 pytorchjob-5c6c22c4-2c8d-49e7-8c2e-46e5fc2caa24 ManualTermination 2024-12-31T14:26:05Z
12qwen2-vl-test-one pytorchjob-ba8b2830-06c6-462f-aaf7-8c2513733482 Succeeded 2024-12-31T14:18:47Z
13
14Navigation:
15q - Quit
16
17Enter command (p/n/q):
- 命令示例(默认资源池)
1$ aihc job list
2
3Page 1 of 1 (Total items: 6)
4
5
6NAME JOB_ID STATUS CREATED_AT
7aihc-createjob-test pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 Created 2025-02-17T07:59:35Z
8qwen2-vl-test-4-copy1 pytorchjob-a53c413c-8e96-416b-8d6a-bc3e1b16a406 Succeeded 2025-01-01T13:22:19Z
9qwen2-vl-test-4 pytorchjob-0389039d-aae5-4601-8e9e-fb230867baa4 ManualTermination 2025-01-01T12:00:52Z
10qwen2-vl-test-one-copy1 pytorchjob-c9ac1567-4306-4085-8432-5305f4dc600f ManualTermination 2024-12-31T15:22:26Z
11qwen2-vl-test-2 pytorchjob-5c6c22c4-2c8d-49e7-8c2e-46e5fc2caa24 ManualTermination 2024-12-31T14:26:05Z
12qwen2-vl-test-one pytorchjob-ba8b2830-06c6-462f-aaf7-8c2513733482 Succeeded 2024-12-31T14:18:47Z
13
14Navigation:
15q - Quit
16
17Enter command (p/n/q):
单任务创建
当前版本的AIHC CLI工具创建任务是基于百舸OpenAPI v1实现,支持的任务参数、校验规则、格式与API一致,建议客户首先阅读 API参考(v1)/训练任务相关接口/创建训练任务 有助于快速上手创建任务命令
直接传参方式创建任务
1# 直接传参方式创建任务
2aihc job create [flags]
3
4Flags:
5 --code-dir string 代码在容器中的挂载路径,默认为 /workspace
6 --code-url string 代码URL,使用代码上传命令返回的URL
7 --command string 指定训练任务的入口命令 (与--script-file二选一)
8 --ds-mountpath string 数据源挂载路径
9 --ds-name string 数据源名称
10 --ds-sourcepath string 数据源挂载路径
11 --ds-type string 数据源类型
12 --enable-bccl 是否启用BCCL,默认false
13 --enable-fault-tolerance 是否启用容错功能,默认false
14 --enable-rdma 是否启用RDMA,默认false
15 --env strings 环境变量 (key=value)
16 --fault-tolerance-args string 容错功能的详细参数
17 --framework string 任务框架类型 (default "pytorch")
18 --gpu strings GPU资源 (type=count)
19 -h, --help help for create
20 --host-network 是否启用主机网络,默认false
21 --image string 容器镜像
22 -f, --job-file strings 任务配置文件路径json/yaml
23 --label strings 标签 (key=value)
24 --local-code string 本地代码路径,创建任务时会先上传代码
25 --name string 任务名称
26 -p, --pool string 资源池ID (如未指定则使用配置文件中的默认值)
27 --priority string 任务优先级 (low/normal/high) (default "normal")
28 --privileged 是否启用特权模式,默认false
29 --replicas int32 任务副本数 (default 1)
30 --script-file string 命令脚本的路径,以脚本的方式指定训练任务的入口命令 (与--command二选一)
- 命令示例
1$ aihc job create --local-code Aihc \
2 --name cli-codeupload-test \
3 --image registry.baidubce.com/inf-qa/nginx:latest \
4 --framework PyTorchJob \
5 --command "sleep 1d" \
6 --replicas 4 \
7 --privileged=true \
8 --fault-tolerance-args="--enable-replace=true --enable-hang-detection=true --hang-detection-log-timeout-minutes=7 --hang-detection-startup-toleration-minutes=15 --hang-detection-stack-timeout-minutes=3 --max-num-of-unconditional-retry=2 --unconditional-retry-observe-seconds=3600 --custom-log-patterns=timeout1 --custom-log-patterns=timeout2 --enable-use-nodes-of-last-job=true --enable-checkpoint-migration=true --internal-fault-tolerance-alarm-phone=10086,10010" \
9 --priority high \
10 --enable-bccl=false \
11 --enable-fault-tolerance=true \
12 --local-code /codeDir/file --code-dir /workspace #代码路径 #代码上传挂载目录
13 -p cce-cm1jjxrq
使用任务模板创建任务
- 命令示例(使用JSON格式模板)
1# 支持使用json格式文件传递参数,详见参数模板,创建任务支持的参数详见创建任务接口参数:https://cloud.baidu.com/doc/AIHC/s/jm56inxn7
2# 接口请求body参数的json文件,需将在命令行运行的主机上先创建好任务信息
3$ aihc job create -f job_info.json
4
5# 使用command文件保存启动命令
6$ aihc job create -f job_info.json --script-file command.txt
7
8#创建任务时上传代码
9
10$ aihc job create -f job-info.yaml --local-code /file/path #本地代码路径
- 上传代码
1# 使用命令上传代码
2aihc code upload --folder /code/filepath
3
4Usage:
5 aihc code upload [flags]
6
7Flags:
8 -f, --folder string 指定要上传的代码文件夹路径
9 -h, --help help for upload
10 -p, --pool string 指定资源池ID,如未指定则使用配置文件中的默认值
11 -q, --queue string 指定队列ID
JSON格式任务参数参考模板:
1{
2 "name": "qwen2-vl-test-4-copy2",
3 "queue": "",
4 "jobFramework": "pytorch",
5 "jobSpec": {
6 "command": "cd /data \u0026\u0026 mkdir qwen2-vl\n\ncp /mnt/ca-p800-poc/llava-en-zh-300k.tar.gz /data/qwen2-vl/\n#cp /mnt/ca-p800-poc/llava-en-zh-2k.tar.gz /data/qwen2-vl/\ncd /data/qwen2-vl\n\ntar -zxvf llava-en-zh-300k.tar.gz \u0026\u0026 rm llava-en-zh-300k.tar.gz\n#tar -zxvf llava-en-zh-2k.tar.gz \u0026\u0026 rm llava-en-zh-2k.tar.gz\n\n# code\ncp /mnt/ca-p800-poc/models/qwen2-vl.tar.gz /home/\ncd /home/\ntar -zxvf qwen2-vl.tar.gz \u0026\u0026 rm qwen2-vl.tar.gz\n\n# model weights\ncp /mnt/ca-p800-poc/Qwen2-VL-7B-Instruct.tar.gz .\ntar -zxvf Qwen2-VL-7B-Instruct.tar.gz \u0026\u0026 rm Qwen2-VL-7B-Instruct.tar.gz\n\n#train lora\ncd /home/qwen2-vl/\nconda activate llamafactory_env\nexport PATH=/root/miniconda/envs/llamafactory_env/bin:$PATH\nexport PYTHONPATH=$PYTHONPATH:/home/qwen2-vl/\n\napt-get install dnsutils -y\npip install deepspeed==0.14.5\n\nsource env.sh\nnohup bash dist_train.sh lora \u0026\n\nsleep 100000",
7 "image": "ccr-2ccrtest-vpc.cnc.bj.baidubce.com/yetao04-ca-test/qwen2vl_p800_image:v1.0",
8 "imageConfig": {
9 "username": "",
10 "password": ""
11 },
12 "replicas": 4,
13 "resources": [
14 {
15 "name": "kunlunxin.com/xpu",
16 "quantity": 8
17 },
18 {
19 "name": "sharedMemory",
20 "quantity": 1024
21 }
22 ],
23 "envs": [
24 {
25 "name": "AIHC_JOB_NAME",
26 "value": "qwen2-vl-test-4-copy1"
27 },
28 {
29 "name": "NCCL_IB_DISABLE",
30 "value": "0"
31 }
32 ],
33 "enableRDMA": true,
34 "hostNetwork": false
35 },
36 "faultTolerance": false,
37 "labels": [
38 {
39 "key": "aijob.cce.baidubce.com/ai-user-id",
40 "value": "ac3553acbb8d4c5e9b212fc0a04c8f7d"
41 },
42 {
43 "key": "aijob.cce.baidubce.com/ai-user-name",
44 "value": "daichaonan"
45 },
46 {
47 "key": "aijob.cce.baidubce.com/create-from-aihcp",
48 "value": "true"
49 },
50 {
51 "key": "aijob.cce.baidubce.com/openapi-jobid",
52 "value": "pytorchjob-a53c413c-8e96-416b-8d6a-bc3e1b16a406"
53 }
54 ],
55 "priority": "high",
56 "datasources": [
57 {
58 "type": "pfsl1",
59 "sourcePath": "/yetao04",
60 "mountPath": "/mnt",
61 "name": "pfs-zesqWP",
62 "options": {
63 "sizeLimit": 1000,
64 "medium": "",
65 "readOnly": false,
66 "pfsL1ClusterIp": "172.16.0.221",
67 "pfsL1ClusterPort": "8888"
68 }
69 },
70 {
71 "type": "hostpath",
72 "sourcePath": "/ssd1",
73 "mountPath": "/data",
74 "name": "hostpath-1",
75 "options": {
76 "sizeLimit": 0,
77 "medium": "",
78 "readOnly": false
79 }
80 }
81 ],
82 "faultToleranceConfig": {
83 "enabledHangDetection": false,
84 "hangDetectionTimeoutMinutes": 0,
85 "faultToleranceLimit": 0,
86 "customFaultTolerancePattern": null
87 },
88 "alertConfig": null,
89 "enableBccl": false
90}
- 命令示例(使用YAML格式模板)
1支持使用yaml格式文件传递参数,详见参数模板,创建任务支持的参数详见创建任务接口参数:https://cloud.baidu.com/doc/AIHC/s/jm56inxn7
2# 接口请求body参数的yaml文件
3$ aihc job create -f ./job_info.yaml
4
5# 创建任务时上传代码及使用command文件保存启动命令
6$ aihc job create -f job_info.yaml --local-code folder --script-file command.txt
YAML格式任务参数参考模板:
1name: qwen2-vl-test-4-cli-test
2queue: ""
3jobFramework: pytorch
4jobSpec:
5 command: |
6 sleep 100000
7 image: ccr-2ccrtest-vpc.cnc.bj.baidubce.com/yetao04-ca-test/qwen2vl_p800_image:v1.0
8 imageConfig:
9 username: ""
10 password: ""
11 replicas: 4
12 resources:
13 - name: kunlunxin.com/xpu
14 quantity: 8
15 - name: rdma/hca
16 quantity: 1
17 - name: sharedMemory
18 quantity: 1024
19 envs:
20 - name: AIHC_JOB_NAME
21 value: qwen2-vl-test-4-copy1
22 - name: NCCL_IB_DISABLE
23 value: "0"
24 enableRDMA: true
25 hostNetwork: false
26faultTolerance: true
27labels:
28 - key: aijob.cce.baidubce.com/ai-user-id
29 value: ac3553acbb8d4c5e9b212fc0a04c8f7d
30 - key: aijob.cce.baidubce.com/ai-user-name
31 value: daichaonan
32 - key: aijob.cce.baidubce.com/create-from-aihcp
33 value: "true"
34 - key: aijob.cce.baidubce.com/openapi-jobid
35 value: pytorchjob-a53c413c-8e96-416b-8d6a-bc3e1b16a406
36priority: high
37codeSource:
38 mountPath: /workspace
39datasources:
40 - type: hostpath
41 sourcePath: /
42 mountPath: /mnt/rapidfs
43 name: rapidfs-p800
44enableBccl: false
45faultToleranceArgs: "--enable-replace=true --enable-hang-detection=true --hang-detection-log-timeout-minutes=7 --hang-detection-startup-toleration-minutes=15 --hang-detection-stack-timeout-minutes=3 --max-num-of-unconditional-retry=2 --unconditional-retry-observe-seconds=3600 --custom-log-patterns=timeout1 --custom-log-patterns=timeout2 --enable-use-nodes-of-last-job=true --enable-checkpoint-migration=true --internal-fault-tolerance-alarm-phone=10086,10010"
批量任务提交
1aihc job create -f job-1.yaml -f job-2.yaml ..-f ..
- 命令示例
1$ aihc job create -f ./job-1.yaml -f ./job-2.yaml
删除训练任务
1aihc job delete jobID [flags]
2 -h, --help help for delete
3 -p, --pool string 资源池ID
- 示例命令
1# 删除指定资源池下任务
2$ aihc job delete pytorchjob-c0d3504cfd-b44b-6dd7c39dde59 -p cce-2k0cj
3
4# 删除默认资源池下任务
5$ aihc job delete pytorchjob-c0d3504cfd-b44b-6dd7c39dde59
停止训练任务
1aihc job stop jobID [flags]
2
3Flags:
4 -h, --help help for stop
5 -p, --pool string 资源池ID
- 示例命令
1# 停止指定资源池下任务
2$ aihc job stop pytorchjob-c0d3504cfd-b44b-6dd7c39dde59 -p cce-2k0cj
3
4# 停止默认资源池下任务
5$ aihc job stop pytorchjob-c0d3504cfd-b44b-6dd7c39dde59
获取任务详情
1aihc job get jobID [flags]
2Flags:
3 -h, --help help for get
4 --pods 是否展示作业的实例信息
5 -p, --pool string 资源池ID
6 -s, --status 显示任务状态简要信息
- 示例命令
1# 获取默认资源池下指定任务详情
2$ aihc job get pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59
3
4# 获取指定资源池下指定任务详情
5$ aihc job get pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 -p cce-2k9sw0cj
6
7Using default pool ID from config: cce-4hw7gn1m
8failed to get job details: [Code: cce.warning.GetAIJobByJobIdFailed; Message: get job by jobid failed, err: pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 not found job; RequestId: a17a6ab1-9045-4346-9f1a-53733c621321]
9(base) luyuchao@luyuchaodeMacBook-Pro ~ % aihc job get pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 -p cce-2k9sw0cj
10openapigetjobresponseresult:
11 jobid: pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59
12 name: aihc-createjob-test
13 resourcepoolid: cce-2k9sw0cj
14 command: sleep 100
15 createdat: "2025-02-17T07:59:35Z"
16 finishedat: ""
17 runningat: ""
18 scheduledat: ""
19 datasources: []
20 enablefaulttolerance: false
21 customfaulttolerancepattern: []
22 labels:
23 - key: aijob.cce.baidubce.com/ai-user-id
24 value: eca97e148cb74e9683d7b7240829d1ff
25 - key: aijob.cce.baidubce.com/ai-user-name
26 value: root
27 - key: aijob.cce.baidubce.com/create-from-aihcp-api
28 value: "true"
29 - key: aijob.cce.baidubce.com/openapi-jobid
30 value: pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59
31 - key: key
32 value: value
33 priority: high
34 queue: default
35 status: Created
36 image: registry.baidubce.com/aihc-aiak/aiak-training-llm
37 resources:
38 - name: baidu.com/a100_80g_cgpu
39 quantity: 8
40 enablerdma: false
41 hostnetwork: false
42 replicas: 2
43 envs:
44 - name: AIHC_JOB_NAME
45 value: aihc-createjob-test
46 - name: AIHC_TENSORBOARD_LOG_PATH
47 value: ""
48 - name: CUDA_DEVICE_MAX_CONNECTIONS
49 value: "1"
50 - name: NCCL_DEBUG
51 value: INFO
52 jobframework: pytorch
53 queueingsequence: null
54 enablebccl: false
55 enablebcclstatus: unknown
56 enablebcclerrorreason: ""
57 k8suid: 3168a331-b584-46c6-b6cc-b01214e217a7
58 k8snamespace: default
59podlist:
60 listmeta:
61 totalitems: 0
62 pods: []
查询任务状态
1aihc job get jobID --status/-s
- 示例命令
1$ aihc job get pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 -p cce-2k9sw0cj -s
2name priority pool/queue replicas status runningAt scheduledAt createdAt
3aihc-createjob-test high cce-2k9sw0cj/default 2 Created 2025-02-17T07:59:35Z
查询任务实例列表
1aihc pod list jobID
- 示例命令
1# 查询指定资源池下指定任务的实例列表
2$ aihc pod list pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 -p cce-2k9sw0cj
3
4# 查询默认资源池下指定任务的实例列表
5$ aihc pod list pytorchjob-a3a7f6cf-43c9-4792-b0e7-fdb454a7555b
6
7replicaType name namespace podPhase status creationTimestamp
8master pxy-moe-48hours-cpu-master-0 default Running Running 2024-12-17T13:22:41Z
连接任务实例
1aihc job exec jobID [flags]
2
3Flags:
4 -c, --container string 容器名称
5 -h, --help help for exec
6 -i, --interactive 保持标准输入打开
7 -n, --namespace string 命名空间 (默认为 default)
8 -p, --pool string 资源池ID
9 -t, --tty 分配伪终端
- 示例命令
1$ aihc job exec pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59 -it pxy-moe-48hours-cpu-master-0 bin/bash
复制任务配置
1aihc job export jobID [flags]
2
3Flags:
4 -h, --help help for export
5 -p, --pool string 资源池ID
- 示例命令
1$ aihc job export pytorchjob-c0d35053-229d-4cfd-b44b-6dd7c39dde59
查询任务日志
1aihc job logs jobID [flags]
2
3Flags:
4 -c, --chunk string 输出日志按着chunk数进行汇聚,例如将10行日志为1条记录,默认0
5 --filepath string 日志文件路径
6 -h, --help help for logs
7 --log-source string 日志来源,例如node
8 --marker string 日志的起始位置,用于分页查询
9 -m, --max-lines string 日志的最大行数
10 -n, --namespace string 命名空间 (默认为 default)
11 --podname string Pod名称
12 -p, --pool string 资源池ID
13 -q, --queue string 队列ID
14 -s, --start-time string 日志的起始时间,unix时间戳
- 示例命令
1$ aihc job logs pytorchjob-a3a7f6cf-43c9-4792-b0e7-fdb454a7555b --podname ui-test-test-running-master-0 -p cce-hcuw9ybk
开发机相关操作
生成开发机创建模板
纯客户端生成,不调用API。
1$ aihc dev template [flags]
2
3Flags:
4 -f, --format string 模板格式:json 或 yaml(默认 json) (default "json")
5 -h, --help help for template
6 -p, --path string 模板生成目录,未指定则生成到当前目录
- 命令示例
1# 默认生成 dev_conf.json 到当前目录
2$ aihc dev template
3dev create template generated: ./dev_conf.json
4
5# 生成 YAML 格式模板到指定目录
6$ aihc dev template -f yaml -p /tmp
7dev create template generated: /tmp/dev_conf.yaml
创建开发机
支持两种方式:模板文件创建(
-f)和逐参数创建。开发机API要求至少提供一个数据卷(--cds-size或--volumn-confs),否则会返回错误。
1$ aihc dev create [flags]
2
3Flags:
4 --accelerator-count int32 加速卡数量
5 --accelerator-type string 加速卡类型(如 NVIDIA_A100)
6 --blb-id string BLB 实例 ID(开启外网访问时必填)
7 --cds-mount string CDS 数据卷挂载路径 (default "/home/work")
8 --cds-size int32 CDS 数据卷容量 (GB)
9 --cpu int32 CPU 核数
10 --creator string 创建者名称
11 --creator-id string 创建者 ID
12 --envs stringArray 环境变量(key=value,可重复)
13 -f, --file string 开发机创建参数文件 (yaml/json),缺省读取当前目录的 dev_conf.yaml
14 -h, --help help for create
15 --image-url string 镜像地址
16 --memory int32 内存 (GB)
17 -n, --name string 开发机名称(标志模式必填)
18 --port-info stringArray 自定义端口(name=xxx,port=NNN,access-port=NNN,可重复)
19 --priority string 调度优先级 (low/normal/high)
20 -q, --queue-name string 队列名称
21 -p, --resource-pool-id string 资源池 ID
22 --resource-pool-name string 资源池名称(部分校验场景需填)
23 --resource-pool-type string 资源池类型(如 common)
24 --shm-size int32 共享内存大小 (GB)
25 --ssh-enable 是否启用 SSH 访问
26 --ssh-rsa-pub-key string SSH RSA 公钥内容
27 --start-cmd string 开发机启动后执行的命令
28 --volumn-confs stringArray 存储卷(type=cds,capacity=100,mount=/foo 或 type=pfs,instance-id=...,source=/x,mount=/y[,read-only=true],可重复)
29 --workspace-dir string 工作目录路径
- 命令示例(模板方式创建)
1# 使用JSON格式模板创建
2$ aihc dev create -f dev_conf.json
3
4# 使用YAML格式模板创建
5$ aihc dev create -f dev_conf.yaml
JSON格式开发机创建参数参考模板(由 aihc dev template 生成):
1{
2 "name": "my-dev",
3 "conf": {
4 "resourcePool": {
5 "resourcePoolType": "serverless",
6 "resourcePoolId": "aihc-xxxxx",
7 "resourcePoolName": "",
8 "queueName": "aihcq-xxxxx"
9 },
10 "resources": {
11 "acceleratorType": "",
12 "acceleratorCount": 0,
13 "cpus": 4,
14 "memory": 16,
15 "shmSize": 8
16 },
17 "image": {
18 "imageType": 0,
19 "imageUrl": "registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04",
20 "username": "",
21 "password": ""
22 },
23 "access": {
24 "blbId": "",
25 "sshEnable": false,
26 "sshRSAPubKey": "",
27 "portInfo": []
28 },
29 "scheduleConf": {
30 "cpuNodeAffinity": false,
31 "priority": "high"
32 },
33 "workspaceDir": "$HOME/workspace",
34 "envs": {},
35 "startCmd": "",
36 "volumnConfs": [
37 {
38 "volumnType": "cds",
39 "pfs": null,
40 "dataset": null,
41 "cfs": null,
42 "cds": {
43 "capacity": 20
44 },
45 "bos": null,
46 "mountPath": "/.rootfs",
47 "readOnly": true
48 }
49 ],
50 "updatedAt": 0
51 },
52 "visibleScope": {
53 "type": 1
54 },
55 "notify": {
56 "notifyRuleId": "",
57 "isOpen": false
58 },
59 "isPublicMgmt": false,
60 "creator": "",
61 "creatorId": ""
62}
YAML格式开发机创建参数参考模板(由 aihc dev template -f yaml 生成):
1conf:
2 access:
3 blbId: ""
4 portInfo: []
5 sshEnable: false
6 sshRSAPubKey: ""
7 envs:
8 k1: v1
9 k2: v2
10 image:
11 imageType: 0
12 imageUrl: registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04
13 password: ""
14 username: ""
15 resourcePool:
16 queueName: aihcq-xxxxx
17 resourcePoolId: aihc-xxxxx
18 resourcePoolName: ""
19 resourcePoolType: serverless
20 resources:
21 acceleratorCount: 0
22 acceleratorType: ""
23 cpus: 4
24 memory: 16
25 shmSize: 8
26 scheduleConf:
27 cpuNodeAffinity: false
28 priority: high
29 startCmd: ""
30 updatedAt: 0
31 volumnConfs:
32 - bos: null
33 cds:
34 capacity: 20
35 cfs: null
36 dataset: null
37 mountPath: /.rootfs
38 pfs: null
39 readOnly: true
40 volumnType: cds
41 workspaceDir: $HOME/workspace
42creator: ""
43creatorId: ""
44isPublicMgmt: false
45name: my-dev
46notify:
47 isOpen: false
48 notifyRuleId: ""
49visibleScope:
50 type: 1
- 命令示例(逐参数方式创建)
1# 基础参数创建
2$ aihc dev create -n dev-cli-test-01 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --cds-size 50
3
4# 带GPU + 优先级 + SSH
5$ aihc dev create -n dev-cli-test-02 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --accelerator-type kunlunxin.com/xpu --accelerator-count 1 --priority high --ssh-enable --cds-size 50
6
7# 带共享内存 + 工作目录 + 启动命令
8$ aihc dev create -n dev-cli-test-03 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --shm-size 8 --workspace-dir /workspace --start-cmd "echo hello" --cds-size 50
9
10# 带环境变量 + 端口映射
11$ aihc dev create -n dev-cli-test-04 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --envs KEY1=val1 --envs KEY2=val2 --port-info name=test,port=8080,access-port=30080 --cds-size 50
12
13# 带存储卷
14$ aihc dev create -n dev-cli-test-05 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --volumn-confs "type=pfs,instance-id=pfs-Eo2rEd,source=/,mount=/mnt/pfs" --cds-size 50
15
16# 带创建者
17$ aihc dev create -n dev-cli-test-06 -p aihc-1oobshtbcwip --resource-pool-type serverless -q aihcq-j5ncoe0w0m2o --image-url ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04 --cpu 2 --memory 8 --creator xxx --cds-size 50
获取开发机列表
1$ aihc dev list/ls [flags]
2
3Flags:
4 -h, --help help for list
5 --name string 按开发机名称模糊过滤
6 --only-my-devs 仅显示我创建的开发机
7 --order string 排序方向:asc(升序) / desc(降序)
8 --order-by string 排序字段:createdAt(创建时间) / updatedAt(更新时间) / name(名称)
9 --pageNo int 页码(从 1 开始) (default 1)
10 -s, --pageSize int 每页数量 (default 50)
11 --query-key string 查询字段名(高级过滤;与 --name 互斥)
12 --query-val string 查询字段值(高级过滤;与 --name 互斥)
13 -q, --queue-name string 按队列名称过滤
14 -p, --resource-pool-id string 按资源池 ID 过滤
15 --status string 按状态过滤(数字状态码,例如 3=运行中、5=已关机)
- 命令示例
1# 列出所有开发机
2$ aihc dev ls
3
4# 按资源池和名称过滤
5$ aihc dev list --resource-pool-id cce-xxxxx --name dev-test --pageNo 1 --pageSize 10
6
7# 只显示我的开发机
8$ aihc dev ls --only-my-devs -s 5
获取开发机详情
1$ aihc dev get <devID> [flags]
2
3Flags:
4 -h, --help help for get
5 -o, --output string 输出格式:table / json / yaml(缺省为 yaml)
- 命令示例
1# 默认YAML格式输出
2$ aihc dev get dv-216e683e1d
3
4# JSON格式输出
5$ aihc dev get dv-f259223fa7 -o json
6
7# 表格格式输出
8$ aihc dev get dv-216e683e1d -o table
输出示例(表格):
1ID dv-c914a799a7
2Name commit-test
3Status running
4Status Reason
5Region bj
6Creator xxx (4ab0a886c9774dfc842db8d481479705)
7Created At 2026-05-27 09:48:24
8Updated At 2026-06-01 14:08:26
9Pool/Queue / aihcq-oh1yq6xr0xak
10Resources 4C/16G
11Image ccr-registry.baidubce.com/aihc/aihc-daft-gpu:0.4.0-cu12.1-py3.11-ubuntu22.04
12NodeIP/PodName 10.0.1.8 / aibox-rc09b3405e6d-d5c9748bb-b88jw
13Jupyter URL https://console.bce.baidu.com/api/aihcbox/proxy/v1/webide/dv-c914a799a7/bj/jupyter
14VSCode URL https://console.bce.baidu.com/api/aihcbox/proxy/v1/webide/dv-c914a799a7/bj/vscode/
删除开发机
1$ aihc dev delete/rm <devID> [flags]
2
3Flags:
4 -h, --help help for delete
- 命令示例
1$ aihc dev delete dv-216e683e1d
开关机
1$ aihc dev start <devID> [flags]
2$ aihc dev stop <devID> [flags]
3
4Flags:
5 -h, --help help for start/stop
- 命令示例
1# 开机
2$ aihc dev start dv-bccbdd9db8
3
4# 关机
5$ aihc dev stop dv-bccbdd9db8
定时停止开发机
1$ aihc dev timed-stop <devID> [flags]
2
3Flags:
4 --delay-sec int32 延迟关机秒数(启用定时关机时必填)
5 --enable 启用/取消定时关机:--enable=true 启用,--enable=false 取消 (default true)
6 -h, --help help for timed-stop
- 命令示例
1# 设置1小时后定时停止
2$ aihc dev timed-stop dv-bccbdd9db8 --delay-sec 3600
3
4# 取消定时停止
5$ aihc dev timed-stop dv-bccbdd9db8 --enable=false
更新开发机配置
需通过
-f指定完整的配置文件 (yaml/json),建议先使用aihc dev export <devID>导出后修改再提交。
1$ aihc dev update <devID> [flags]
2
3Flags:
4 -f, --file string 更新配置文件 (yaml/json),必填
5 -h, --help help for update
- 命令示例
1# 导出当前配置
2$ aihc dev export dv-f4cdd6964d -o /tmp/dev_upd.json -f json
3
4# 修改配置文件后更新
5$ aihc dev update dv-f4cdd6964d -f /tmp/dev_upd.json
变更参数文件示例(dev_update.yaml):
1name: new-dev-name
2conf:
3 image:
4 imageUrl: registry.baidubce.com/aihc/pytorch:2.0.0
5 resources:
6 cpus: 16
7 memory: 64
提交开发机为镜像
1$ aihc dev commit <devID> [flags]
2
3Flags:
4 -h, --help help for commit
5 --image-name string 镜像名称(必填)
6 --image-tag string 镜像 Tag (default "latest")
7 --namespace string 镜像命名空间(必填)
8 --password string 镜像仓库密码
9 --registry string 镜像仓库地址(必填)
10 --username string 镜像仓库用户名
- 命令示例
1$ aihc dev commit dv-e78be903d7 \
2 --image-name dev-cli-test-img2 \
3 --namespace zzq \
4 --image-tag v1 \
5 --registry ccr-registry.baidubce.com
查看镜像制作任务详情
通过
--image-pack-job-id指定镜像任务ID(一般在aihc dev commit时返回)。
1$ aihc dev img-list <devID> [flags]
2
3Flags:
4 -h, --help help for img-list
5 --image-pack-job-id string 镜像任务 ID(必填)
- 命令示例
1$ aihc dev img-list dv-e78be903d7 --image-pack-job-id tk-6db402058f
查看开发机事件
1$ aihc dev events <devID> [flags]
2
3Flags:
4 --end-time string 结束时间
5 -t, --event-type string 事件类型(如 Normal/Warning)
6 -h, --help help for events
7 -i, --interactive 启用交互式翻页 (n/p/q)
8 --message string 按消息内容过滤
9 --pageNo int 页码(从 1 开始) (default 1)
10 -s, --pageSize int 页大小 (default 10)
11 --start-time string 开始时间
- 命令示例
1$ aihc dev events dv-e78be903d7 \
2 --start-time "2026-05-21T00:00:00Z" \
3 --end-time "2026-05-27T23:59:59Z" \
4 -t Warning --message "probe" \
5 --pageNo 1 -s 3
导出开发机配置
导出配置可用于
create -f和update -f,实现导出→修改→创建/更新闭环。
1$ aihc dev export <devID> [flags]
2
3Flags:
4 -f, --format string 输出格式:json / yaml(默认 json,大小写不敏感) (default "json")
5 -h, --help help for export
6 -o, --output string 输出文件路径
- 命令示例
1# 导出为JSON格式
2$ aihc dev export dv-c914a799a7 -o /tmp/dev_exp.json -f json
3/tmp/dev_exp.json
4
5# 导出为YAML格式
6$ aihc dev export dv-c914a799a7 -o /tmp/dev_exp.yaml -f yaml
7/tmp/dev_exp.yaml
推理服务相关操作
生成推理服务创建模板
纯客户端生成,不调用API。
1$ aihc service template [flags]
2
3Flags:
4 -f, --format string 模板格式:json 或 yaml(默认 json) (default "json")
5 -h, --help help for template
6 -p, --path string 模板生成目录,未指定则生成到当前目录
- 命令示例
1# 默认生成 service_conf.json 到当前目录
2$ aihc service template
3service create template generated: ./service_conf.json
4
5# 生成 YAML 格式模板到指定目录
6$ aihc service template -f yaml -p /tmp
7service create template generated: /tmp/service_conf.yaml
YAML格式推理服务创建参数参考模板(由 aihc service template -f yaml 生成):
1# 推理服务创建模板。提交时使用: aihc service create -f service_conf.yaml
2name: "" # 服务名称(必填)
3instanceCount: 1 # 实例副本数
4acceleratorType: "" # 加速芯片类型(如 NVIDIA-A100)
5
6# === 容器配置 ===
7containers:
8 - name: main # 容器名称
9 cpus: 8 # CPU 核数
10 memory: 32 # 内存 GB
11 acceleratorCount: 1 # GPU 卡数
12 command: # 启动命令
13 - python
14 - /workspace/app.py
15 image:
16 imageType: 1 # 0=公共镜像 1=自定义镜像
17 imageUrl: "" # 镜像地址
18 username: ""
19 password: ""
20 ports: # 端口映射
21 - name: HTTP
22 port: 8000
23 envs: # 环境变量
24 MODEL_NAME: deepseek-r1
25
26# === 存储配置 ===
27storage:
28 shmSize: 10 # 共享内存大小 (GB)
29 volumns:
30 - volumeType: pfs
31 volumnName: model-pfs
32 pfs:
33 sourcePath: /mnt/models
34 mountPath: /workspace/models
35
36# === 资源池配置 ===
37resourcePool:
38 resourcePoolId: "" # 资源池 ID
39 resourcePoolName: "" # 资源池名称
40 queueName: "" # 队列名称
41
42# === 调度配置 ===
43deploy:
44 schedule:
45 priority: normal # low | normal | high
46
47# === 流量接入 ===
48access:
49 publicAccess: false
50 networkType: aiGateway # aiGateway | blb
51 aiGateway:
52 enableAuth: true
53
54# === 高级配置 ===
55misc:
56 gracePeriodSec: 30
57 fedPodsPerIns: 0
创建推理服务
支持两种方式:模板文件创建(
-f)和逐参数创建。-f支持 JSON 和 YAML 格式,通过文件内容自动判断格式(以{或[开头按 JSON 处理,否则按 YAML 处理)。
1$ aihc service create [flags]
2
3Flags:
4 --accelerator-count int32 加速卡数量(第一个容器)
5 --accelerator-type string 加速卡类型(如 NVIDIA-A100)
6 --command string 启动命令(第一个容器)
7 --containers string 自定义容器 JSON 字符串(多容器场景,与逐参数标志互斥)
8 --cpus int32 CPU 核数(第一个容器)
9 --envs stringArray 环境变量(key=value,可重复)
10 -f, --file string 推理服务创建参数文件 (yaml/json),缺省读取当前目录的 service_conf.yaml
11 -h, --help help for create
12 --image-url string 镜像地址(作用于第一个容器)
13 --instance-count int32 实例副本数 (default 1)
14 --memory int32 内存 GB(第一个容器)
15 -n, --name string 服务名称(标志模式必填)
16 --network-type string 网络类型:aiGateway / blb
17 --ports stringArray 端口映射(name=HTTP,port=8000,可重复)
18 --priority string 调度优先级 (low/normal/high)
19 --public-access 开启公网访问
20 -q, --queue-name string 队列名称
21 -p, --resource-pool-id string 资源池 ID
22 --resource-pool-name string 资源池名称
23 --resource-pool-type string 资源池类型(空字符串=自运维, serverless=全托管)
24 --volumns stringArray 存储卷(type=pfs,source=/mnt,mount=/workspace,可重复)
- 命令示例(模板方式创建)
1# 使用JSON文件创建
2$ aihc service create -f test_service.json
3
4# 使用YAML文件创建
5$ aihc service create -f test_service.yaml
- 命令示例(逐参数方式创建)
1# 基础参数创建
2$ aihc service create --name test-cli-create-01 \
3 --resource-pool-id cce-1ov7onxr --queue-name default \
4 --image-url registry.baidubce.com/aiak-inference/aiak-inference-comfyui:ubuntu22.04-cu12.4-torch2.5.1-py310_v1.2 \
5 --cpus 4 --memory 16 --instance-count 1
6
7# 完整参数创建(GPU + 命令 + 环境变量 + 端口 + 优先级 + 网络类型)
8$ aihc service create --name test-cli-create-02 \
9 --resource-pool-id cce-1ov7onxr --queue-name default \
10 --image-url registry.baidubce.com/aiak-inference/aiak-inference-comfyui:ubuntu22.04-cu12.4-torch2.5.1-py310_v1.2 \
11 --cpus 4 --memory 16 --accelerator-type NVIDIA-A100 --accelerator-count 1 \
12 --instance-count 1 --command "python /workspace/app.py" \
13 --envs MODEL_NAME=test-model --envs DEBUG=true \
14 --ports name=HTTP,port=8000 --priority high --network-type aiGateway
15
16# 带存储卷
17$ aihc service create --name test-cli-create-03 \
18 --resource-pool-id cce-1ov7onxr --queue-name default \
19 --image-url registry.baidubce.com/aiak-inference/aiak-inference-comfyui:ubuntu22.04-cu12.4-torch2.5.1-py310_v1.2 \
20 --cpus 2 --memory 8 --instance-count 1 \
21 --volumns "type=pfs,source=/mnt/models,mount=/workspace/models,instance-id=pfs-xxxx"
22
23# 带资源池名称
24$ aihc service create --name test-cli-create-rpn \
25 --resource-pool-id cce-1ov7onxr --resource-pool-name aihclite-regress-infer \
26 --queue-name default \
27 --image-url registry.baidubce.com/aiak-inference/aiak-inference-comfyui:ubuntu22.04-cu12.4-torch2.5.1-py310_v1.2 \
28 --cpus 2 --memory 8 --accelerator-type NVIDIA-A100 --accelerator-count 1 --instance-count 1
获取推理服务列表
注意:OpenAPI当前不返回服务状态信息,故列表中无状态列。
1$ aihc service list/ls [flags]
2
3Flags:
4 -h, --help help for list
5 -n, --name string 按名称关键字过滤(客户端过滤)
6 --order string 排序方向:asc(升序)/desc(降序)
7 --order-by string 排序字段:createdAt(创建时间)/updatedAt(更新时间)/name(名称)
8 --pageNo int 页码(从 1 开始) (default 1)
9 -s, --pageSize int 每页数量 (default 50)
10 -p, --resource-pool-id string 按资源池 ID 过滤(客户端过滤)
- 命令示例
1# 列出指定资源池的服务
2$ aihc service list --resource-pool-id cce-1ov7onxr --name test --pageNo 1 --pageSize 10
3
4# 使用短标志和排序
5$ aihc service ls -p cce-1ov7onxr -n ctest --pageNo 1 -s 5 --order-by createdAt --order desc
6
7# 升序排列
8$ aihc service list -p cce-1ov7onxr -n test -s 5 --order-by createdAt --order asc
获取推理服务详情
1$ aihc service get <serviceID> [flags]
2
3Flags:
4 -h, --help help for get
5 -o, --output string 输出格式:table / json / yaml(缺省为 yaml,大小写不敏感)
- 命令示例
1# 默认YAML格式输出
2$ aihc service get s-ref4993b9dd5
3
4# JSON格式输出
5$ aihc service get s-ref4993b9dd5 -o json
6
7# 表格格式输出
8$ aihc service get s-r53254a7b418 -o table
删除推理服务
只支持删除标准推理服务,不支持删除多角色推理服务。
1$ aihc service delete/rm <serviceID> [flags]
2
3Flags:
4 -h, --help help for delete
- 命令示例
1$ aihc service delete s-r36caeaf78fa
更新推理服务
需通过
-f指定完整的配置文件 (yaml/json),建议先使用aihc service export <serviceID>导出后修改再提交。注意:仅支持修改 acceleratorType/instanceCount/storage/containers/log/deploy/misc,name 和 resourcePool 不可修改;serverless 资源池的服务可能因 API 限制无法更新。
1$ aihc service update <serviceID> [flags]
2
3Flags:
4 -d, --description string 更新描述
5 -f, --file string 更新配置文件 (yaml/json),必填
6 -h, --help help for update
- 命令示例
1# 导出当前配置
2$ aihc service export s-r53254a7b418 -o /tmp/update_test.json -f json
3
4# 修改配置文件后更新
5$ aihc service update s-r53254a7b418 -f /tmp/update_test.json -d "test update cpus to 6"
变更参数文件示例(service_update.yaml):
1description: "升级到 v2.0 模型"
2containers:
3 - name: main
4 image:
5 imageUrl: registry.baidubce.com/aihc/vllm:v2.0.0
扩缩容
1$ aihc service scale <serviceID> [flags]
2
3Flags:
4 -h, --help help for scale
5 --instance-count int32 目标实例数量(必填,0 表示缩容至零) (default -1)
- 命令示例
1# 扩容到2个实例
2$ aihc service scale s-r53254a7b418 --instance-count 2
配置公网访问
仅 AI 原生网关(aiGateway)类型支持,BLB 负载均衡类型不支持。开启公网访问需绑定 EIP,否则 API 会返回错误。
1$ aihc service net-config <serviceID> [flags]
2
3Flags:
4 --eip string 绑定的弹性公网 IP(可选)
5 -h, --help help for net-config
6 --public-access string 开启/关闭公网访问 (true/false) (default "false")
- 命令示例
1# 开启公网访问
2$ aihc service net-config s-r15dcaf6a0a4 --public-access true
3
4# 关闭公网访问
5$ aihc service net-config s-r15dcaf6a0a4 --public-access false
6
7# 开启公网访问并绑定EIP
8$ aihc service net-config s-r15dcaf6a0a4 --public-access true --eip "1.2.3.4"
重启推理服务
重启操作通过删除 Pod 触发平台重建实现。不指定
-i时重启整个服务(逐个重建所有 Pod),指定-i时重建指定实例。
1$ aihc service restart <serviceID> [flags]
2
3Flags:
4 -h, --help help for restart
5 -i, --instance-id string 指定实例 ID
- 命令示例
1# 重启整个服务
2$ aihc service restart s-r53254a7b418
3
4# 重启指定实例
5$ aihc service restart s-r53254a7b418 -i s-r53254a7b418-67477dc4b8-7r65v
查看Pod列表
不支持多角色服务。API不支持分页,故CLI无
--pageNo/--pageSize参数。
1$ aihc service pods <serviceID> [flags]
2
3Flags:
4 -h, --help help for pods
- 命令示例
1$ aihc service pods s-r53254a7b418
查看实例组列表
仅用于开启分布式部署的标准服务,不支持多角色服务。
1$ aihc service pod-groups <serviceID> [flags]
2
3Flags:
4 -h, --help help for pod-groups
- 命令示例
1$ aihc service pod-groups s-f41e42d5c6fe
删除Pod(触发重建)
1$ aihc service pod-delete <serviceID> [flags]
2
3Flags:
4 -h, --help help for pod-delete
5 -i, --instance-id string 实例 ID(必填)
- 命令示例
1# 先查看Pod列表获取实例ID
2$ aihc service pods s-r53254a7b418
3
4# 删除指定Pod,将自动触发重建
5$ aihc service pod-delete s-r53254a7b418 -i s-r53254a7b418-98bdc687-wcr7b
摘流/恢复
1$ aihc service disable-service-pod <serviceID> [flags]
2
3Flags:
4 --block true=摘除流量 / false=恢复流量 (default true)
5 -h, --help help for disable-service-pod
6 -i, --instance-id string 实例 ID(必填)
- 命令示例
1# 摘流
2$ aihc service disable-service-pod s-r70a6f998e10 -i s-r70a6f998e10-677c7d89b-j49dj --block=true
3
4# 恢复流量
5$ aihc service disable-service-pod s-r70a6f998e10 -i s-r70a6f998e10-677c7d89b-j49dj --block=false
进入服务容器终端
通过 WebSocket 连接进入容器终端。需 Pod 处于 Running 状态,且容器中需有
/bin/bash。
1$ aihc service exec <serviceID> [flags]
2
3Flags:
4 --handshake-timeout-second int32 建连超时(秒),默认 30 (default 30)
5 -h, --help help for exec
6 -i, --instance-id string 实例 ID(必填)
7 --ping-timeout-second int32 心跳超时(秒),默认 900 (default 900)
8 -q, --queue string 队列名称或 ID
9 -p, --resource-pool-id string 资源池 ID
10 --resource-pool-type string 资源池类型
- 命令示例
1$ aihc service exec s-r640c92f3d2a -i s-r640c92f3d2a-7bc6f8f859-749tg -p aihc-serverless -q aihcq-tkdtuz8q6ud9 --resource-pool-type serverless
查看推理服务日志
支持分页(通过 marker 翻页)和实时跟踪(
--follow)。与job logs对齐,支持 follow 和非 follow 两种模式。
1$ aihc service logs <serviceID> [flags]
2
3Flags:
4 -c, --container string 容器名称
5 -e, --end-time string 日志结束时间(RFC3339 格式,如 2026-03-27T01:40:35Z)
6 -f, --follow 实时跟踪日志
7 -h, --help help for logs
8 -i, --instance-id string 实例 ID(必填)
9 --marker string 日志起始位置,用于分页(取上一次返回的 nextMarker)
10 -m, --max-lines int32 最大行数 (default 100)
11 -n, --namespace string 命名空间(默认为 default)
12 -s, --start-time string 日志起始时间(RFC3339 格式,如 2026-03-20T01:40:35Z)
- 命令示例
1# 查看指定时间范围的日志
2$ aihc service logs s-r045298c51cb \
3 -i s-r045298c51cb-5b558cf964-bb2cs \
4 -s "2026-05-27T00:00:00Z" \
5 -e "2026-05-27T20:00:00Z" \
6 -m 50
7
8# 持续输出日志(follow模式)
9$ aihc service logs s-r045298c51cb \
10 -i s-r045298c51cb-5b558cf964-bb2cs \
11 -f
查看变更记录
1$ aihc service changelog <serviceID> [changeID] [flags]
2
3Flags:
4 -h, --help help for changelog
5 --pageNo int 页码(从 1 开始) (default 1)
6 -s, --pageSize int 每页数量 (default 50)
- 命令示例
1# 查看变更记录列表
2$ aihc service changelog s-r53254a7b418
3
4# 查看某条变更详情
5$ aihc service changelog s-r8294f7229c4 ch-2b4a8b7a33d0 --pageNo 1 -s 20
导出推理服务配置
导出配置可用于
create -f和update -f,实现导出→修改→创建/更新闭环。
1$ aihc service export <serviceID> [flags]
2
3Flags:
4 -f, --format string 输出格式:json / yaml(默认 json,大小写不敏感) (default "json")
5 -h, --help help for export
6 -o, --output string 输出文件路径
- 命令示例
1# 默认导出JSON格式到当前目录
2$ aihc service export s-ref4993b9dd5
3./service_export.json
4
5# 导出JSON到指定路径
6$ aihc service export s-ref4993b9dd5 -o /tmp/test_j.json -f json
7/tmp/test_j.json
8
9# 导出YAML到指定路径
10$ aihc service export s-ref4993b9dd5 -o /tmp/test_y.yaml -f yaml
11/tmp/test_y.yaml
透传请求OpenAPI
透传请求 AIHC 的 OpenAPI,自动附带 BCE V1 签名。用法与原生 curl 保持一致,仅自动处理百度云鉴权签名。
支持请求百舸已开放的全部OpenAPI,接口参数详见API参考
1aihc curl <URL> [flags]
2
3Flags:
4 -d, --data string 请求body数据(JSON字符串)
5 -H, --header strings 自定义header,格式 'Key: Value',可多次指定
6 -h, --help help for curl
7 -X, --request string 请求method: GET/POST/PUT/DELETE (default "GET")
8
9Global Flags:
10 -C, --config string Global configuration file. (default "./.aihc/config")
- 命令示例
1# GET 请求(查询数据集列表)
2aihc curl '/?action=DescribeDatasets' -X GET -H "version: v2"
3
4# GET 请求带分页参数
5aihc curl '/?action=DescribeDatasets&pageSize=10&pageNumber=1' -X GET -H "version: v2"
6
7# POST 请求(创建数据集)
8aihc curl '/?action=CreateDataset' -X POST -H "version: v2" -d '{"name":"test","storageType":"PFS"}'
9
10# 指定完整 host
11aihc curl 'http://aihc.bj.baidubce.com/?action=DescribeDatasets' -X GET -H "version: v2"
评价此篇文章
