

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# AWS Batch 支持 A SageMaker I 训练作业
<a name="training-job-queues"></a>

[AWS Batch 作业队列](https://docs.aws.amazon.com/batch/latest/userguide/job_queues.html)会在提交的作业在计算资源上运行之前，对其进行存储并确定优先级。您可以将 SageMaker AI 训练作业提交到作业队列，以便利用提供的无服务器作业计划和优先级划分工具。 AWS Batch

## 工作原理
<a name="training-job-queues-how-it-works"></a>

以下步骤描述了如何将 AWS Batch 作业队列与 SageMaker AI 训练作业配合使用的工作流程。有关更详细的教程和示例笔记本，请参阅[开始使用](#training-job-queues-get-started)部分。
+ 设置 AWS Batch 和任何必要的权限。有关更多信息，请参阅《AWS Batch 用户指南》**中的[设置 AWS Batch](https://docs.aws.amazon.com/batch/latest/userguide/get-set-up-for-aws-batch.html)。
+ 在控制台中或使用创建以下 AWS Batch 资源 AWS CLI：
  + [服务环境](https://docs.aws.amazon.com/batch/latest/userguide/service-environments.html)-包含用于与 SageMaker AI 集成的配置参数。
  + [SageMaker AI 训练作业队列](https://docs.aws.amazon.com/batch/latest/userguide/create-sagemaker-job-queue.html) — 与 SageMaker AI 集成以提交训练作业。
+ 配置您的详细信息并请求 A SageMaker I 训练作业，例如您的训练容器镜像。要向 AWS Batch 队列提交训练作业，你可以使用 适用于 Python (Boto3) 的 AWS SDK、或 SageMaker AI Python SDK。 AWS CLI
+ 将训练作业提交到作业队列。您可以使用以下选项来提交作业：
  + 使用 AWS Batch [SubmitServiceJob](https://docs.aws.amazon.com/batch/latest/APIReference/API_SubmitServiceJob.html) API。
  + 使用 SageMaker AI Python 软件开发工具包中的[`aws_batch`模块](https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/aws_batch)。创建 TrainingQueue 对象和模型训练对象（例如 Estimator 或 ModelTrainer）后，您可以使用 TrainingQueue 方法向提交训练作业。`queue.submit()`
+ 提交作业后，使用 AWS Batch 控制台、API 或 SageMaker A AWS Batch [DescribeServiceJob[DescribeTrainingJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeTrainingJob.html)](https://docs.aws.amazon.com/batch/latest/APIReference/API_DescribeServiceJob.html)I API 查看您的任务队列和任务状态。

## 成本和可用性
<a name="training-job-queues-cost-availability"></a>

有关训练作业的详细定价信息，请参阅 [Amazon A SageMaker I 定价](https://aws.amazon.com/sagemaker-ai/pricing/)。使用 AWS Batch，您只需为使用的任何 AWS 资源（例如 Amazon EC2 实例）付费。有关更多信息，请参阅[AWS Batch 定价](https://aws.amazon.com/batch/pricing/)。

您可以在任何有训练作业 AWS 区域 的地方用 AWS Batch 于 SageMaker AI 训练作业。有关更多信息，请参阅 [Amazon A SageMaker I 终端节点和配额](https://docs.aws.amazon.com/general/latest/gr/sagemaker.html)。

为了确保在需要时拥有所需的容量，您可以使用 SageMaker AI 灵活训练计划 (FTP)。这些计划可让您为训练作业预留容量。与 AWS Batch的排队功能结合使用时，您可以在计划有效期内最大限度地提高利用率。有关更多信息，请参阅[为您预留训练任务或 HyperPod 集群的训练计划](https://docs.aws.amazon.com/sagemaker/latest/dg/reserve-capacity-with-training-plans.html)。

## 开始使用
<a name="training-job-queues-get-started"></a>

有关如何设置 AWS Batch 作业队列和提交 SageMaker AI 训练作业的教程，请参阅*AWS Batch 用户指南*中的 [ SageMaker AI 入门](https://docs.aws.amazon.com/batch/latest/userguide/getting-started-sagemaker.html)。 AWS Batch 

有关展示如何在 AI Py SageMaker thon SDK 中使用该`aws_batch`模块的 Jupyter 笔记本，请参阅存储库[AWS Batch 中的 SageMaker AI Training 作业笔记本示例](https://github.com/aws/amazon-sagemaker-examples/tree/default/%20%20%20%20%20%20build_and_train_models/sm-training-queues)。 amazon-sagemaker-examples GitHub 