

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

# 使用 SageMaker API 在訓練計畫上建立 SageMaker HyperPod 叢集，或 AWS CLI
<a name="use-training-plan-for-hyperpod-creation-using-api-cli-sdk"></a>

若要針對您的 Amazon SageMaker HyperPod 叢集使用 SageMaker 訓練計畫，請在呼叫 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateCluster.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateCluster.html) API 操作時，在 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ClusterInstanceGroupSpecification.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ClusterInstanceGroupSpecification.html) 的 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ClusterInstanceGroupSpecification.html#sagemaker-Type-ClusterInstanceGroupSpecification-TrainingPlanArn](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ClusterInstanceGroupSpecification.html#sagemaker-Type-ClusterInstanceGroupSpecification-TrainingPlanArn) 參數中指定您要使用的訓練計畫 ARN。

確定與您計劃所指定 AZ 相關聯的子網路包含在叢集組態的 `VPCConfig` 中。您可以在 [``DescribeTrainingPlan](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeTrainingPlan.html) API 呼叫的回應中擷取訓練計畫的 `AvailabilityZone`。

下列範例說明如何建立新的 SageMaker HyperPod 叢集，並在 `create-cluster` AWS CLI 命令的 `--instance-groups` 屬性中為執行個體群組提供訓練計劃。

```
# Create a cluster         
aws sagemaker create-cluster \
  --cluster-name cluster-name \
  --instance-groups '[ \
        { \
            "InstanceCount": 1,\
            "InstanceGroupName": "controller-nodes",\
            "InstanceType": "ml.t3.xlarge",\
            "LifeCycleConfig": {"SourceS3Uri": source_s3_uri, "OnCreate": "on_create.sh"},\
            "ExecutionRole": "arn:aws:iam::customer_account_id:role/execution_role",\
            "ThreadsPerCore": 1,\
        },\
        { \
            "InstanceCount": 2, \
            "InstanceGroupName": "worker-nodes",\
            "InstanceType": "p4d.24xlarge",\
            "LifeCycleConfig": {"SourceS3Uri": source_s3_uri, "OnCreate": "on_create.sh"},\
            "ExecutionRole": "arn:aws:iam::customer_account_id}:role/execution_role}",\
            "ThreadsPerCore": 1,\
            "TrainingPlanArn": training_plan_arn,\
        }]'
```

如需如何使用 建立 HyperPod 叢集的資訊 AWS CLI，請參閱 [https://docs.aws.amazon.com/cli/latest/reference/sagemaker/create-cluster.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/create-cluster.html)。

建立叢集後，您可以透過呼叫 `DescribeCluster` API 來驗證您的執行個體群組是否已從訓練計畫正確地獲指派容量。

```
aws sagemaker describe-cluster --cluster-name cluster-name
```