

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# SageMaker HyperPod Slurm クラスター用の複数のコントローラーノードのセットアップ
<a name="sagemaker-hyperpod-multihead-slurm-setup"></a>

このトピックでは、ライフサイクルスクリプトを使用して SageMaker HyperPod Slurm クラスターで複数のコントローラー (ヘッド) ノードを設定する方法について説明します。開始する前に、「[SageMaker HyperPod を使用するための前提条件](sagemaker-hyperpod-prerequisites.md)」に記載されている前提条件を確認し、「[ライフサイクルスクリプトを使用して SageMaker HyperPod クラスターをカスタマイズする](sagemaker-hyperpod-lifecycle-best-practices-slurm.md)」のライフサイクルスクリプトを理解しておく必要があります。このトピックの手順では、Amazon Linux 環境で AWS CLI コマンドを使用します。これらのコマンドで使用される環境変数は、明示的に保持されない限り、現在のセッションで使用できることに注意が必要です。

**Topics**
+ [CloudFormation スタックを使用したリソースのプロビジョニング](sagemaker-hyperpod-multihead-slurm-cfn.md)
+ [IAM ポリシーを作成してアタッチする](sagemaker-hyperpod-multihead-slurm-iam.md)
+ [ライフサイクルスクリプトの準備とアップロード](sagemaker-hyperpod-multihead-slurm-scripts.md)
+ [SageMaker HyperPod クラスターの作成](sagemaker-hyperpod-multihead-slurm-create.md)
+ [重要な注意事項の考慮](sagemaker-hyperpod-multihead-slurm-notes.md)
+ [環境変数のリファレンスの確認](sagemaker-hyperpod-multihead-slurm-variables-reference.md)

# CloudFormation スタックを使用したリソースのプロビジョニング
<a name="sagemaker-hyperpod-multihead-slurm-cfn"></a>

HyperPod Slurm クラスターに複数のコントローラーノードを設定するには、 [リソースをプロビジョンする](#sagemaker-hyperpod-multihead-slurm-cfn-basic)と の 2 つの CloudFormation スタックを使用してリソースをプロビジョニング AWS します[複数のコントローラーノードをサポートするように追加のリソースをプロビジョンする](#sagemaker-hyperpod-multihead-slurm-cfn-multihead)。

## リソースをプロビジョンする
<a name="sagemaker-hyperpod-multihead-slurm-cfn-basic"></a>

Amazon SageMaker HyperPod Slurm クラスターの基本的なリソースをプロビジョンするには、次の手順に従います。

1. [sagemaker-hyperpod.yaml](https://github.com/aws-samples/awsome-distributed-training/blob/main/1.architectures/5.sagemaker-hyperpod/sagemaker-hyperpod.yaml) テンプレートファイルをマシンにダウンロードします。この YAML ファイルは、Slurm クラスター用に作成する以下のリソースを定義する CloudFormation テンプレートです。
   + コンピューティングノードインスタンスグループの実行 IAM ロール
   + ライフサイクルスクリプトを保存する Amazon S3 バケット
   + パブリックサブネットとプライベートサブネット (プライベートサブネットには NAT ゲートウェイを介したインターネットアクセスがあります）
   + インターネットゲートウェイ/NAT ゲートウェイ
   + 2 つの Amazon EC2 セキュリティグループ
   + 設定ファイルを保存する Amazon FSx ボリューム

1. 次の CLI コマンドを実行して、 という名前の CloudFormation スタックを作成します`sagemaker-hyperpod`。`PrimarySubnetAZ` および `BackupSubnetAZ` でクラスターのアベイラビリティーゾーン (AZ) ID を定義します。たとえば、*use1-az4* は、`us-east-1` リージョンのアベイラビリティーゾーンの AZ ID です。詳細については、「[アベイラビリティーゾーン ID](https://docs.aws.amazon.com//ram/latest/userguide/working-with-az-ids.html)」と「[複数の AZ にまたがる SageMaker HyperPod クラスターのセットアップ](sagemaker-hyperpod-prerequisites.md#sagemaker-hyperpod-prerequisites-multiple-availability-zones)」を参照してください。

   ```
   aws cloudformation deploy \
   --template-file /path_to_template/sagemaker-hyperpod.yaml \
   --stack-name sagemaker-hyperpod \
   --parameter-overrides PrimarySubnetAZ=use1-az4 BackupSubnetAZ=use1-az1 \
   --capabilities CAPABILITY_IAM
   ```

   詳細については、「 AWS Command Line Interface リファレンス」の[「デプロイ](https://docs.aws.amazon.com//cli/latest/reference/cloudformation/deploy/)」を参照してください。スタックの作成が完了するまでに数分かかる場合があります。完了すると、コマンドラインインターフェイスに以下が表示されます。

   ```
   Waiting for changeset to be created..
   Waiting for stack create/update to complete
   Successfully created/updated stack - sagemaker-hyperpod
   ```

1. (オプション) [CloudFormation コンソール](https://console.aws.amazon.com/cloudformation/home)でスタックを検証します。
   + 左のナビゲーションメニューから [**スタック**] を選択します。
   + **[スタック]** ページで、**sagemaker-hyperpod** を探して選択します。
   + **[リソース]** や **[出力]** などのタブを選択して、リソースと出力を確認します。

1. スタック (`sagemaker-hyperpod`) 出力から環境変数を作成します。これらの変数の値は [複数のコントローラーノードをサポートするように追加のリソースをプロビジョンする](#sagemaker-hyperpod-multihead-slurm-cfn-multihead) に使用します。

   ```
   source .env
   PRIMARY_SUBNET=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`PrimaryPrivateSubnet`].OutputValue' --output text)
   BACKUP_SUBNET=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`BackupPrivateSubnet`].OutputValue' --output text)
   EMAIL=$(bash -c 'read -p "INPUT YOUR SNSSubEmailAddress HERE: " && echo $REPLY')
   DB_USER_NAME=$(bash -c 'read -p "INPUT YOUR DB_USER_NAME HERE: " && echo $REPLY')
   SECURITY_GROUP=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`SecurityGroup`].OutputValue' --output text)
   ROOT_BUCKET_NAME=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`AmazonS3BucketName`].OutputValue' --output text)
   SLURM_FSX_DNS_NAME=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`FSxLustreFilesystemDNSname`].OutputValue' --output text)
   SLURM_FSX_MOUNT_NAME=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`FSxLustreFilesystemMountname`].OutputValue' --output text)
   COMPUTE_NODE_ROLE=$(aws --region $REGION cloudformation describe-stacks --stack-name $SAGEMAKER_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`AmazonSagemakerClusterExecutionRoleArn`].OutputValue' --output text)
   ```

   E メールアドレスとデータベースユーザー名の入力を求めるプロンプトが表示されたら、以下のとおり値を入力します。

   ```
   INPUT YOUR SNSSubEmailAddress HERE: Email_address_to_receive_SNS_notifications
   INPUT YOUR DB_USER_NAME HERE: Database_user_name_you_define
   ```

   変数の値を検証するには、`print $variable` コマンドを使用します。

   ```
   print $REGION
   us-east-1
   ```

## 複数のコントローラーノードをサポートするように追加のリソースをプロビジョンする
<a name="sagemaker-hyperpod-multihead-slurm-cfn-multihead"></a>

複数のコントローラーノードを持つ Amazon SageMaker HyperPod Slurm クラスターに追加のリソースをプロビジョンするには、次の手順に従います。

1. [sagemaker-hyperpod-slurm-multi-headnode.yaml](https://github.com/aws-samples/awsome-distributed-training/blob/main/1.architectures/5.sagemaker-hyperpod/sagemaker-hyperpod-slurm-multi-headnode.yaml) テンプレートファイルをマシンにダウンロードします。この 2 番目の YAML ファイルは、Slurm クラスターで複数のコントローラーノードをサポートするために作成する追加のリソースを定義する CloudFormation テンプレートです。
   + コンピューティングノードインスタンスグループの実行 IAM ロール
   + Amazon RDS for MariaDB インスタンス
   + Amazon SNS トピックとサブスクリプション
   + AWS Secrets Manager Amazon RDS for MariaDB の 認証情報

1. 次の CLI コマンドを実行して、 という名前の CloudFormation スタックを作成します`sagemaker-hyperpod-mh`。この 2 番目のスタックは、 CloudFormation テンプレートを使用して、複数のコントローラーノードアーキテクチャをサポートする追加の AWS リソースを作成します。

   ```
   aws cloudformation deploy \
   --template-file /path_to_template/slurm-multi-headnode.yaml \
   --stack-name sagemaker-hyperpod-mh \
   --parameter-overrides \
   SlurmDBSecurityGroupId=$SECURITY_GROUP \
   SlurmDBSubnetGroupId1=$PRIMARY_SUBNET \
   SlurmDBSubnetGroupId2=$BACKUP_SUBNET \
   SNSSubEmailAddress=$EMAIL \
   SlurmDBUsername=$DB_USER_NAME \
   --capabilities CAPABILITY_NAMED_IAM
   ```

   詳細については、「 AWS Command Line Interface リファレンス」の[「デプロイ](https://docs.aws.amazon.com//cli/latest/reference/cloudformation/deploy/)」を参照してください。スタックの作成が完了するまでに数分かかる場合があります。完了すると、コマンドラインインターフェイスに以下が表示されます。

   ```
   Waiting for changeset to be created..
   Waiting for stack create/update to complete
   Successfully created/updated stack - sagemaker-hyperpod-mh
   ```

1. (オプション) [AWS Cloud Formation コンソール](https://console.aws.amazon.com/cloudformation/home)でスタックを検証します。
   + 左のナビゲーションメニューから [**スタック**] を選択します。
   + **[スタック]** ページで、**sagemaker-hyperpod-mh** を探して選択します-。
   + **[リソース]** や **[出力]** などのタブを選択して、リソースと出力を確認します。

1. スタック (`sagemaker-hyperpod-mh`) 出力から環境変数を作成します。これらの変数の値を使用して、[ライフサイクルスクリプトの準備とアップロード](sagemaker-hyperpod-multihead-slurm-scripts.md) の設定ファイル (`provisioning_parameters.json`) を更新します。

   ```
   source .env
   SLURM_DB_ENDPOINT_ADDRESS=$(aws --region us-east-1 cloudformation describe-stacks --stack-name $MULTI_HEAD_SLURM_STACK --query 'Stacks[0].Outputs[?OutputKey==`SlurmDBEndpointAddress`].OutputValue' --output text)
   SLURM_DB_SECRET_ARN=$(aws --region us-east-1 cloudformation describe-stacks --stack-name $MULTI_HEAD_SLURM_STACK --query 'Stacks[0].Outputs[?OutputKey==`SlurmDBSecretArn`].OutputValue' --output text)
   SLURM_EXECUTION_ROLE_ARN=$(aws --region us-east-1 cloudformation describe-stacks --stack-name $MULTI_HEAD_SLURM_STACK --query 'Stacks[0].Outputs[?OutputKey==`SlurmExecutionRoleArn`].OutputValue' --output text)
   SLURM_SNS_FAILOVER_TOPIC_ARN=$(aws --region us-east-1 cloudformation describe-stacks --stack-name $MULTI_HEAD_SLURM_STACK --query 'Stacks[0].Outputs[?OutputKey==`SlurmFailOverSNSTopicArn`].OutputValue' --output text)
   ```

# IAM ポリシーを作成してアタッチする
<a name="sagemaker-hyperpod-multihead-slurm-iam"></a>

このセクションでは、IAM ポリシーを作成し、[複数のコントローラーノードをサポートするように追加のリソースをプロビジョンする](sagemaker-hyperpod-multihead-slurm-cfn.md#sagemaker-hyperpod-multihead-slurm-cfn-multihead) で作成した実行ロールにアタッチする方法について説明します。

1. [IAM ポリシーの例](https://github.com/aws-samples/awsome-distributed-training/blob/main/1.architectures/5.sagemaker-hyperpod/1.AmazonSageMakerClustersExecutionRolePolicy.json)を GitHub リポジトリからマシンにダウンロードします。

1. ダウンロードした例を使用して、[create-policy](https://docs.aws.amazon.com//cli/latest/reference/iam/create-policy.html) CLI コマンドで IAM ポリシーを作成します。

   ```
   aws --region us-east-1 iam create-policy \
       --policy-name AmazonSagemakerExecutionPolicy \
       --policy-document file://1.AmazonSageMakerClustersExecutionRolePolicy.json
   ```

   コマンドの出力例

   ```
   {
       "Policy": {
           "PolicyName": "AmazonSagemakerExecutionPolicy",
           "PolicyId": "ANPAXISIWY5UYZM7WJR4W",
           "Arn": "arn:aws:iam::111122223333:policy/AmazonSagemakerExecutionPolicy",
           "Path": "/",
           "DefaultVersionId": "v1",
           "AttachmentCount": 0,
           "PermissionsBoundaryUsageCount": 0,
           "IsAttachable": true,
           "CreateDate": "2025-01-22T20:01:21+00:00",
           "UpdateDate": "2025-01-22T20:01:21+00:00"
       }
   }
   ```

1. [attach-role-policy](https://docs.aws.amazon.com//cli/latest/reference/iam/attach-role-policy.html) CLI コマンドを使用して、[複数のコントローラーノードをサポートするように追加のリソースをプロビジョンする](sagemaker-hyperpod-multihead-slurm-cfn.md#sagemaker-hyperpod-multihead-slurm-cfn-multihead) で作成した `AmazonSagemakerExecutionPolicy` ポリシーを Slurm 実行ロールにアタッチします。

   ```
   aws --region us-east-1 iam attach-role-policy \
       --role-name AmazonSagemakerExecutionRole \
       --policy-arn arn:aws:iam::111122223333:policy/AmazonSagemakerExecutionPolicy
   ```

   このコマンドでは、出力が生成されません。

   (オプション) 環境変数を使用する場合のコマンドの例は、以下のとおりです。
   + ロール名とポリシー名を取得するには 

     ```
     POLICY=$(aws --region $REGION iam list-policies --query 'Policies[?PolicyName==AmazonSagemakerExecutionPolicy].Arn' --output text)
     ROLENAME=$(aws --region $REGION iam list-roles --query "Roles[?Arn=='${SLURM_EXECUTION_ROLE_ARN}'].RoleName" —output text)
     ```
   +  ポリシーをアタッチするには

     ```
     aws  --region us-east-1 iam attach-role-policy \
          --role-name $ROLENAME --policy-arn $POLICY
     ```

詳細については、「[SageMaker HyperPod の IAM ロール](sagemaker-hyperpod-prerequisites-iam.md#sagemaker-hyperpod-prerequisites-iam-role-for-hyperpod)」を参照してください。

# ライフサイクルスクリプトの準備とアップロード
<a name="sagemaker-hyperpod-multihead-slurm-scripts"></a>

必要なすべてのリソースを作成したら、SageMaker HyperPod クラスター用の[ライフサイクルスクリプト](https://github.com/aws-samples/awsome-distributed-training/tree/main/1.architectures/5.sagemaker-hyperpod/LifecycleScripts)を設定する必要があります。これらの[ライフサイクルスクリプト](https://github.com/aws-samples/awsome-distributed-training/tree/main/1.architectures/5.sagemaker-hyperpod/LifecycleScripts)は、基本的な HyperPod Slurm クラスターの作成に使用できる[基本設定](https://github.com/aws-samples/awsome-distributed-training/tree/main/1.architectures/5.sagemaker-hyperpod/LifecycleScripts/base-config)を提供します。

## ライフサイクルスクリプトを準備する
<a name="sagemaker-hyperpod-multihead-slurm-prepare-scripts"></a>

ライフサイクルスクリプトを入手するには、次の手順を実行します。

1. GitHub リポジトリからマシンに[ライフサイクルスクリプト](https://github.com/aws-samples/awsome-distributed-training/tree/main/1.architectures/5.sagemaker-hyperpod/LifecycleScripts)をダウンロードします。

1. [cp](https://docs.aws.amazon.com//cli/latest/reference/s3/cp.html) CLI コマンドを使用して、[リソースをプロビジョンする](sagemaker-hyperpod-multihead-slurm-cfn.md#sagemaker-hyperpod-multihead-slurm-cfn-basic) で作成した Amazon S3 バケットに[ライフサイクルスクリプト](https://github.com/aws-samples/awsome-distributed-training/tree/main/1.architectures/5.sagemaker-hyperpod/LifecycleScripts)をアップロードします。

   ```
   aws s3 cp --recursive LifeCycleScripts/base-config s3://${ROOT_BUCKET_NAME}/LifeCycleScripts/base-config
   ```

## 設定ファイルを作成する
<a name="sagemaker-hyperpod-multihead-slurm-update-config-file"></a>

以下の手順に従って設定ファイルを作成し、ライフサイクルスクリプトを保存するのと同じ Amazon S3 バケットにアップロードします。

1. 以下の設定を使用して、`provisioning_parameters.json` と言う名前の設定ファイルを追加します。なお、`slurm_sns_arn` はオプションです。指定しない場合、HyperPod は Amazon SNS 通知をセットアップしません。

   ```
   cat <<EOF > /tmp/provisioning_parameters.json
   {
     "version": "1.0.0",
     "workload_manager": "slurm",
     "controller_group": "$CONTOLLER_IG_NAME",
     "login_group": "my-login-group",
     "worker_groups": [
       {
         "instance_group_name": "$COMPUTE_IG_NAME",
         "partition_name": "dev"
       }
     ],
     "fsx_dns_name": "$SLURM_FSX_DNS_NAME",
     "fsx_mountname": "$SLURM_FSX_MOUNT_NAME",
     "slurm_configurations": {
       "slurm_database_secret_arn": "$SLURM_DB_SECRET_ARN",
       "slurm_database_endpoint": "$SLURM_DB_ENDPOINT_ADDRESS",
       "slurm_shared_directory": "/fsx",
       "slurm_database_user": "$DB_USER_NAME",
       "slurm_sns_arn": "$SLURM_SNS_FAILOVER_TOPIC_ARN"
     }
   }
   EOF
   ```

1. ライフサイクルスクリプトを保存するのと同じ Amazon S3 バケットに `provisioning_parameters.json` ファイルをアップロードします。

   ```
   aws s3 cp /tmp/provisioning_parameters.json s3://${ROOT_BUCKET_NAME}/LifeCycleScripts/base-config/provisioning_parameters.json
   ```
**注記**  
API 駆動型設定を使用している場合、 `provisioning_parameters.json`ファイルは必須ではありません。API 駆動型設定では、CreateCluster API ペイロードで Slurm ノードタイプ、パーティション、FSx マウントを直接定義します。詳細については、[「 を使用した SageMaker HyperPod の開始方法 AWS CLI](smcluster-getting-started-slurm-cli.md)」を参照してください。

## Amazon S3 バケット内のファイルを検証する
<a name="sagemaker-hyperpod-multihead-slurm-verify-s3"></a>

すべてのライフサイクルスクリプトと `provisioning_parameters.json` ファイルをアップロードすると、Amazon S3 バケットは次のようになります。

![\[Amazon Simple Storage Service コンソールで Amazon S3 バケットにアップロードされたすべてのライフサイクルスクリプトを示す画像\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/images/hyperpod/hyperpod-lifecycle-scripts-s3.png)


詳細については、「[HyperPod が提供する基本ライフサイクルスクリプトを使用して開始する](https://docs.aws.amazon.com//sagemaker/latest/dg/sagemaker-hyperpod-lifecycle-best-practices-slurm-slurm-base-config.html)」を参照してください。

# SageMaker HyperPod クラスターの作成
<a name="sagemaker-hyperpod-multihead-slurm-create"></a>

必要なすべてのリソースを設定し、スクリプトを Amazon S3 バケットにアップロードしたら、クラスターを作成できます。

1. クラスターを作成するには、 [https://docs.aws.amazon.com//cli/latest/reference/sagemaker/create-cluster.html](https://docs.aws.amazon.com//cli/latest/reference/sagemaker/create-cluster.html) AWS CLI コマンドを実行します。作成プロセスには、最大 15 分かかる場合があります。

   ```
   aws --region $REGION sagemaker create-cluster \
       --cluster-name $HP_CLUSTER_NAME \
       --vpc-config '{
           "SecurityGroupIds":["'$SECURITY_GROUP'"],
           "Subnets":["'$PRIMARY_SUBNET'", "'$BACKUP_SUBNET'"]
       }' \
       --instance-groups '[{                  
       "InstanceGroupName": "'$CONTOLLER_IG_NAME'",
       "InstanceType": "ml.t3.medium",
       "InstanceCount": 2,
       "LifeCycleConfig": {
           "SourceS3Uri": "s3://'$BUCKET_NAME'",
           "OnCreate": "on_create.sh"
       },
       "ExecutionRole": "'$SLURM_EXECUTION_ROLE_ARN'",
       "ThreadsPerCore": 1
   },
   {
       "InstanceGroupName": "'$COMPUTE_IG_NAME'",          
       "InstanceType": "ml.c5.xlarge",
       "InstanceCount": 2,
       "LifeCycleConfig": {
           "SourceS3Uri": "s3://'$BUCKET_NAME'",
           "OnCreate": "on_create.sh"
       },
       "ExecutionRole": "'$COMPUTE_NODE_ROLE'",
       "ThreadsPerCore": 1
   }]'
   ```

   実行が正常に完了すると、コマンドは次のようなクラスター ARN を返します。

   ```
   {
       "ClusterArn": "arn:aws:sagemaker:us-east-1:111122223333:cluster/cluster_id"
   }
   ```

1. (オプション) クラスターのステータスを確認するには、SageMaker AI コンソール ([https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)) を使用できます。左側のナビゲーションから **[HyperPod クラスター]** を選択し、**[クラスターの管理]** をクリックします。クラスターの名前を選択して、クラスターの詳細ページを開きます。クラスターが正常に作成されていると、クラスターのステータスが **[InService]** と表示されます。  
![\[Amazon SageMaker AI コンソールに複数のコントローラーノードがある HyperPod Slurm クラスターを示す画像\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/images/hyperpod/hyperpod-lifecycle-multihead-cluster.png)

# 重要な注意事項の考慮
<a name="sagemaker-hyperpod-multihead-slurm-notes"></a>

このセクションでは、役に立つ重要な注意事項をいくつか説明します。

1. マルチコントローラー Slurm クラスターに移行するには、以下の手順を実行します。

   1. 「[CloudFormation スタックを使用したリソースのプロビジョニング](sagemaker-hyperpod-multihead-slurm-cfn.md)」の手順に従って、必要なすべてのリソースをプロビジョンします。

   1. 「[ライフサイクルスクリプトの準備とアップロード](sagemaker-hyperpod-multihead-slurm-scripts.md)」の手順に従って、更新したライフサイクルスクリプトをアップロードします。`provisioning_parameters.json` ファイルを更新する際は、既存のコントローラーグループを [`worker_groups`] セクションに移動し、[`controller_group`] セクションに新しいコントローラーグループ名を追加します。

   1. [update-cluster](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/update-cluster.html) API コールを実行して新しいコントローラーグループを作成し、元のコンピューティングインスタンスグループとコントローラーグループを保持します。

1. コントローラーノードの数をスケールダウンするには、[update-cluster](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/update-cluster.html) CLI コマンドを使用します。各コントローラーインスタンスグループについて、スケールダウンできるコントローラーノードの最小数は 1 です。つまり、コントローラーノードの数を 0 にスケールダウンすることはできません。
**重要**  
2025 年 1 月 24 日より前に作成されたクラスターの場合、[update-cluster](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/update-cluster.html) CLI コマンドを実行する前に、まず [UpdateClusterSoftware](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateClusterSoftware.html) API を使用してクラスターソフトウェアを更新する必要があります。

   以下は、コントローラーノードの数をスケールダウンする CLI コマンドの例です。

   ```
   aws sagemaker update-cluster \
       --cluster-name my_cluster \
       --instance-groups '[{                  
       "InstanceGroupName": "controller_ig_name",
       "InstanceType": "ml.t3.medium",
       "InstanceCount": 3,
       "LifeCycleConfig": {
           "SourceS3Uri": "s3://amzn-s3-demo-bucket1",
           "OnCreate": "on_create.sh"
       },
       "ExecutionRole": "slurm_execution_role_arn",
       "ThreadsPerCore": 1
   },
   {
       "InstanceGroupName": "compute-ig_name",       
       "InstanceType": "ml.c5.xlarge",
       "InstanceCount": 2,
       "LifeCycleConfig": {
           "SourceS3Uri": "s3://amzn-s3-demo-bucket1",
           "OnCreate": "on_create.sh"
       },
       "ExecutionRole": "compute_node_role_arn",
       "ThreadsPerCore": 1
   }]'
   ```

1. コントローラーノードをバッチ削除するには、[batch-delete-cluster-nodes](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/batch-delete-cluster-nodes.html) CLI コマンドを使用します。コントローラーインスタンスグループごとに、少なくとも 1 つのコントローラーノードを保持する必要があります。すべてのコントローラーノードをバッチ削除しようとしても、この API オペレーションは機能しません。
**重要**  
2025 年 1 月 24 日より前に作成されたクラスターの場合、[batch-delete-cluster-nodes](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/batch-delete-cluster-nodes.html) CLI コマンドを実行する前に、まず [UpdateClusterSoftware](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateClusterSoftware.html) API を使用してクラスターソフトウェアを更新する必要があります。

   以下は、コントローラーノードの数をバッチ削除する CLI コマンドの例です。

   ```
   aws sagemaker batch-delete-cluster-nodes --cluster-name my_cluster --node-ids instance_ids_to_delete
   ```

1. クラスター作成の問題をトラブルシューティングするには、SageMaker AI コンソールのクラスターの詳細ページから失敗メッセージを確認します。CloudWatch ログを使用して、クラスター作成に関する問題をトラブルシューティングすることもできます。CloudWatch コンソールから、**[ロググループ]** をクリックします。次に、`clusters` を検索して、クラスターの作成に関連するロググループのリストを確認します。  
![\[CloudWatch コンソールの Amazon SageMaker HyperPod クラスターロググループを示す画像\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/images/hyperpod/hyperpod-lifecycle-multihead-logs.png)

# 環境変数のリファレンスの確認
<a name="sagemaker-hyperpod-multihead-slurm-variables-reference"></a>

[SageMaker HyperPod Slurm クラスター用の複数のコントローラーノードのセットアップ](sagemaker-hyperpod-multihead-slurm-setup.md) のチュートリアルでは、次の環境変数が定義され、使用されます。これらの環境変数は、明示的に保持されていない限り、現在のセッションでのみ使用できます。これらは `$variable_name` 構文を使用して定義されています。キーと値のペアを持つ変数は AWS作成されたリソースを表し、キーを持たない変数はユーザー定義です。


**環境変数のリファレンス**  

| 可変 | 説明 | 
| --- | --- | 
| \$1BACKUP\$1SUBNET |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1COMPUTE\$1IG\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1COMPUTE\$1NODE\$1ROLE |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1CONTOLLER\$1IG\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1DB\$1USER\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1EMAIL |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1PRIMARY\$1SUBNET |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1POLICY |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1REGION |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1ROOT\$1BUCKET\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SECURITY\$1GROUP |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1DB\$1ENDPOINT\$1ADDRESS |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1DB\$1SECRET\$1ARN |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1EXECUTION\$1ROLE\$1ARN |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1FSX\$1DNS\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1FSX\$1MOUNT\$1NAME |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 
| \$1SLURM\$1SNS\$1FAILOVER\$1TOPIC\$1ARN |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/sagemaker-hyperpod-multihead-slurm-variables-reference.html)  | 