

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

# 使用 CloudFormation 模板创建 SageMaker HyperPod 集群
<a name="smcluster-getting-started-eks-console-create-cluster-cfn"></a>

您可以使用的 CloudFormation 模板创建 SageMaker HyperPod 集群 HyperPod。必须安装 AWS CLI 才能继续。

**Topics**
+ [在控制台中配置资源并使用进行部署 CloudFormation](#smcluster-getting-started-eks-console-create-cluster-deploy-console)
+ [使用配置和部署资源 CloudFormation](#smcluster-getting-started-eks-console-create-cluster-deploy-cfn)

## 在控制台中配置资源并使用进行部署 CloudFormation
<a name="smcluster-getting-started-eks-console-create-cluster-deploy-console"></a>

您可以使用配置资源 AWS 管理控制台 并使用 CloudFormation模板进行部署。

执行以下步骤。

1. 不要@@ *选择 “**提交**”，而*是在教程结尾处选择 “**下载 CloudFormation 模板参数**” [开始 SageMaker HyperPod 使用 SageMaker AI 控制台](smcluster-getting-started-slurm-console.md)。本教程包含成功创建集群所需的重要配置信息。
**重要**  
如果您选择**提交**，则在删除集群之前，无法部署同名集群。

   选择**下载 CloudFormation 模板参数**后，页面右侧将出现 “**使用配置文件使用该 AWS CLI窗口创建集群**”。

1. 在**使用配置文件通过 AWS CLI创建集群**窗口上，选择**下载配置参数文件**。该文件将下载到您的计算机上。可以根据需要编辑配置 JSON 文件，如果不需要进行更改，也可以将其保持原样。

1. 在终端，导航到参数文件 `file://params.json` 的位置。

1. 运行 [create-stack](https://docs.aws.amazon.com//cli/latest/reference/cloudformation/create-stack.html) AWS CLI 命令部署 CloudFormation 堆栈，该堆栈将预配置的资源并创建集群。 HyperPod

   ```
   aws cloudformation create-stack 
       --stack-name my-stack
       --template-url https://aws-sagemaker-hyperpod-cluster-setup.amazonaws.com/templates-slurm/main-stack-slurm-based-template.yaml
       --parameters file://params.json
       --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM
   ```

1. 要查看资源配置的状态，请导航到[CloudFormation 控制台](https://console.aws.amazon.com/cloudformation)。

   集群创建完成后，在 SageMaker HyperPod控制台主窗格的 “**集群**” 下查看新集群。您可以查看**状态**栏下显示的状态。

1. 集群状态变为 `InService` 后，即可开始登录集群节点。要访问集群节点并开始运行 ML 工作负载，请参阅 [SageMaker HyperPod 集群上的作业](sagemaker-hyperpod-run-jobs-slurm.md)。

## 使用配置和部署资源 CloudFormation
<a name="smcluster-getting-started-eks-console-create-cluster-deploy-cfn"></a>

您可以使用的 CloudFormation 模板配置和部署资源 SageMaker HyperPod。

执行以下步骤。

1.  SageMaker HyperPod 从[sagemaker-hyperpod-cluster-setup](https://github.com/aws/sagemaker-hyperpod-cluster-setup) GitHub 存储库下载的 CloudFormation 模板。

1. 运行 [create-stack](https://docs.aws.amazon.com//cli/latest/reference/cloudformation/create-stack.html) AWS CLI 命令部署 CloudFormation 堆栈，该堆栈将预配置的资源并创建集群。 HyperPod

   ```
   aws cloudformation create-stack 
       --stack-name my-stack
       --template-url URL_of_the_file_that_contains_the_template_body
       --parameters file://params.json
       --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM
   ```

1. 要查看资源预置的状态，请导航到 CloudFormation 控制台。

   集群创建完成后，在 SageMaker HyperPod控制台主窗格的 “**集群**” 下查看新集群。您可以查看**状态**栏下显示的状态。

1. 集群状态变为 `InService` 后，即可开始登录集群节点。