

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 CloudFormation 範本建立 SageMaker HyperPod 叢集
<a name="smcluster-getting-started-eks-console-create-cluster-cfn"></a>

您可以使用 HyperPod 的 CloudFormation 範本來建立 SageMaker 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. 在 [使用 SageMaker AI 主控台開始使用 SageMaker HyperPod](smcluster-getting-started-slurm-console.md) 的教學課程結束時選擇**下載 CloudFormation 範本參數**，*而不是選擇**提交***。教學課程包含您成功建立叢集所需的重要組態資訊。
**重要**  
如果您選擇**提交**，在刪除叢集之前，您將無法部署名稱相同的叢集。

   在選擇**下載 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>

您可以使用 SageMaker HyperPod 的 CloudFormation 範本來設定和部署資源。

請遵循下列步驟。

1. 從 [sagemaker-hyperpod-cluster-setup](https://github.com/aws/sagemaker-hyperpod-cluster-setup) GitHub 儲存庫下載 SageMaker HyperPod 的 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` 之後，您可以開始登入叢集節點。