本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
HyperPod 任务管理 AWS CLI 命令示例
您可以通过 Kubectl 或通过自定义 HyperPod CLI HyperPod 与 EKS 一起使用。您可以通过 Studio 或通过 Studio 使用这些命令 AWS CLI。以下提供了 SageMaker HyperPod 任务管理示例,说明如何使用 HyperPod AWS CLI 命令查看集群详细信息。有关更多信息,包括如何安装,请参阅 HyperPod CLI Github 存储库
获取集群加速器设备配额信息
以下示例命令获取有关集群加速器设备配额的信息。
hyperpod get-clusters -n hyperpod-ns-test-team
本示例中的命名空间是根据创建计算分配时提供的团队名称在 Kubernetes 中创建的。hyperpod-ns-test-team
test-team
有关更多信息,请参阅 编辑策略。
示例响应:
[ { "Cluster": "hyperpod-eks-test-
cluster-id
", "InstanceType": "ml.g5.xlarge", "TotalNodes": 2, "AcceleratorDevicesAvailable": 1, "NodeHealthStatus=Schedulable": 2, "DeepHealthCheckStatus=Passed": "N/A", "Namespaces": { "hyperpod-ns-test-team": { "TotalAcceleratorDevices": 1, "AvailableAcceleratorDevices": 1 } } } ]
向 SageMaker AI 管理的队列和命名空间提交任务
以下示例命令将任务提交到您的 HyperPod集群。如果您只能访问一支队伍,则在这种情况下, HyperPod AWS CLI 将自动为您分配队列。否则,如果发现多个队列,我们将显示所有可行的选项供您选择。
hyperpod start-job --job-name hyperpod-cli-test --job-kind kubeflow/PyTorchJob --image docker.io/kubeflowkatib/pytorch-mnist-cpu:v1beta1-bc09cfd --entry-script /opt/pytorch-mnist/mnist.py --pull-policy IfNotPresent --instance-type ml.g5.xlarge --node-count 1 --tasks-per-node 1 --results-dir ./result --priority training-priority
优先级类别在集群策略中定义,该策略定义了如何确定任务的优先级和分配空闲计算的方式。当数据科学家提交工作时,他们会使用其中一个优先级类别的名称,格式为
。在此示例中,priority-class-name
-prioritytraining-priority
指名为 “训练” 的优先级类。有关策略概念的更多信息,请参阅策略。
如果未指定优先级类别,则该作业将被视为低优先级作业,任务排名值为 0。
如果指定了优先级类别,但与群集策略中定义的优先级类别之一不对应,则提交将失败,并且会显示一条错误消息,提供一组已定义的优先级类别。
您也可以使用以下命令使用 YAML 配置文件提交作业:
hyperpod start-job --config-file ./
yaml-configuration-file-name
.yaml
以下是 YAML 配置文件示例,它等同于提交上面讨论的作业。
defaults: - override hydra/job_logging: stdout hydra: run: dir: . output_subdir: null training_cfg: entry_script: /opt/pytorch-mnist/mnist.py script_args: [] run: name: hyperpod-cli-test nodes: 1 ntasks_per_node: 1 cluster: cluster_type: k8s instance_type: ml.g5.xlarge custom_labels: kueue.x-k8s.io/priority-class: training-priority cluster_config: label_selector: required: sagemaker.amazonaws.com/node-health-status: - Schedulable preferred: sagemaker.amazonaws.com/deep-health-check-status: - Passed weights: - 100 pullPolicy: IfNotPresent base_results_dir: ./result container: docker.io/kubeflowkatib/pytorch-mnist-cpu:v1beta1-bc09cfd env_vars: NCCL_DEBUG: INFO
或者,您可以使用提交作业,kubectl
以确保任务显示在 “控制面板” 选项卡中。以下是 kubectl 命令的示例。
kubectl apply -f ./
yaml-configuration-file-name
.yaml
提交任务时,请附上您的队列名称和优先级类别标签。例如,对于队列名称hyperpod-ns-
和优先级类别team-name
-localqueue
,必须包含以下标签:priority-class-name
-priority
-
kueue.x-k8s.io/queue-name: hyperpod-ns-
team-name
-localqueue -
kueue.x-k8s.io/priority-class:
priority-class-name
-priority
以下 YAML 配置片段演示了如何向原始配置文件添加标签以确保您的任务显示在 “控制面板” 选项卡中:
metadata: name:
job-name
namespace: hyperpod-ns-team-name
labels: kueue.x-k8s.io/queue-name: hyperpod-ns-team-name
-localqueue kueue.x-k8s.io/priority-class:priority-class-name
-priority
列出任务
以下命令列出了任务及其详细信息。
hyperpod list-jobs
示例响应:
{ "jobs": [ { "Name": "hyperpod-cli-test", "Namespace": "hyperpod-ns-test-team", "CreationTime": "2024-11-18T21:21:15Z", "Priority": "training", "State": "Succeeded" } ] }
获取工作详细信息
以下命令提供作业的详细信息。如果未指定命名空间,则 HyperPod AWS CLI 将获取您有权访问的 SageMaker AI 管理的命名空间。
hyperpod get-job --job-name hyperpod-cli-test
示例响应:
{ "Name": "hyperpod-cli-test", "Namespace": "hyperpod-ns-test-team", "Label": { "app": "hyperpod-cli-test", "app.kubernetes.io/managed-by": "Helm", "kueue.x-k8s.io/priority-class": "training" }, "CreationTimestamp": "2024-11-18T21:21:15Z", "Status": { "completionTime": "2024-11-18T21:25:24Z", "conditions": [ { "lastTransitionTime": "2024-11-18T21:21:15Z", "lastUpdateTime": "2024-11-18T21:21:15Z", "message": "PyTorchJob hyperpod-cli-test is created.", "reason": "PyTorchJobCreated", "status": "True", "type": "Created" }, { "lastTransitionTime": "2024-11-18T21:21:17Z", "lastUpdateTime": "2024-11-18T21:21:17Z", "message": "PyTorchJob hyperpod-ns-test-team/hyperpod-cli-test is running.", "reason": "PyTorchJobRunning", "status": "False", "type": "Running" }, { "lastTransitionTime": "2024-11-18T21:25:24Z", "lastUpdateTime": "2024-11-18T21:25:24Z", "message": "PyTorchJob hyperpod-ns-test-team/hyperpod-cli-test successfully completed.", "reason": "PyTorchJobSucceeded", "status": "True", "type": "Succeeded" } ], "replicaStatuses": { "Worker": { "selector": "training.kubeflow.org/job-name=hyperpod-cli-test,training.kubeflow.org/operator-name=pytorchjob-controller,training.kubeflow.org/replica-type=worker", "succeeded": 1 } }, "startTime": "2024-11-18T21:21:15Z" }, "ConsoleURL": "https://us-west-2.console.aws.amazon.com/sagemaker/home?region=us-west-2#/cluster-management/hyperpod-eks-test-
cluster-id
“ }
暂停和取消暂停作业
如果要从调度器中删除一些已提交的作业,请 HyperPod AWS CLI 提供suspend
命令以暂时从编排中删除该作业。除非通过命令手动取消暂停的作业,否则将不再安排已暂停的unsuspend
作业
要临时暂停作业,请执行以下操作:
hyperpod patch-job suspend --job-name hyperpod-cli-test
要将任务重新添加到队列中,请执行以下操作:
hyperpod patch-job unsuspend --job-name hyperpod-cli-test
调试作业
HyperPod AWS CLI 还提供了其他命令供您调试作业提交问题。例如list-pods
,get-logs
在 HyperPod AWS CLI Github 存储库中。