カスタム AMIs によるクラスター管理 - Amazon SageMaker AI

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

カスタム AMIs によるクラスター管理

カスタム AMI を構築したら、Amazon SageMaker HyperPod クラスターの作成または更新に使用できます。新しい AMI を使用するインスタンスグループをスケールアップまたは追加することもできます。

クラスターオペレーションに必要なアクセス許可

SageMaker HyperPod クラスターを操作および設定するクラスター管理者ユーザーに次のアクセス許可を追加します。次のポリシー例には、クラスター管理者が SageMaker HyperPod コア APIs、カスタム AMI を使用して SageMaker HyperPod クラスターを管理するための最小限のアクセス許可のセットが含まれています。

AMI および AMI EBS スナップショット共有アクセス許可は、次のポリシーの一部として ModifyImageAttributeおよび ModifySnapshotAttribute API アクセス許可を通じて含まれることに注意してください。共有アクセス許可の範囲を絞り込むには、次の手順を実行します。

  • AMI および AMI スナップショットへの AMI 共有アクセス許可を制御するタグを追加します。たとえば、AMI に を AllowSharingとしてタグ付けできますtrue

  • ポリシーにコンテキストキーを追加して、特定のタグでタグ付けされた AMI の AMIs 共有のみを許可します。

次のポリシーは、 AllowSharingでタグ付けされた AMIs のみが許可されるようにスコープダウンされたポリシーtrueです。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::111122223333:role/your-execution-role-name" }, { "Effect": "Allow", "Action": [ "sagemaker:CreateCluster", "sagemaker:DeleteCluster", "sagemaker:DescribeCluster", "sagemaker:DescribeCluterNode", "sagemaker:ListClusterNodes", "sagemaker:ListClusters", "sagemaker:UpdateCluster", "sagemaker:UpdateClusterSoftware", "sagemaker:BatchDeleteClusterNodes", "eks:DescribeCluster", "eks:CreateAccessEntry", "eks:DescribeAccessEntry", "eks:DeleteAccessEntry", "eks:AssociateAccessPolicy", "iam:CreateServiceLinkedRole", "ec2:DescribeImages", "ec2:DescribeSnapshots" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ec2:ModifyImageAttribute", "ec2:ModifySnapshotAttribute" ], "Resource": "*", "Condition": { "StringEquals": { "ec2:ResourceTag/AllowSharing": "true" } } } ] }

クラスターを作成する

CreateCluster オペレーションの ImageIdフィールドでカスタム AMI を指定できます。

次の例は、カスタム AMI を使用してクラスターを作成する方法を示しています。

aws sagemaker create-cluster \ --cluster-name <exampleClusterName> \ --orchestrator 'Eks={ClusterArn='<eks_cluster_arn>'}' \ --node-provisioning-mode Continuous \ --instance-groups '{ "InstanceGroupName": "<exampleGroupName>", "InstanceType": "ml.c5.2xlarge", "InstanceCount": 2, "LifeCycleConfig": { "SourceS3Uri": "<s3://amzn-s3-demo-bucket>", "OnCreate": "on_create_noop.sh" }, "ImageId": "<your_custom_ami>", "ExecutionRole": "<arn:aws:iam::444455556666:role/Admin>", "ThreadsPerCore": 1, "InstanceStorageConfigs": [ { "EbsVolumeConfig": { "VolumeSizeInGB": 200 } } ] }' --vpc-config '{ "SecurityGroupIds": ["<security_group>"], "Subnets": ["<subnet>"] }'

クラスターソフトウェアを更新する

クラスター上の既存のインスタンスグループをカスタム AMI で更新する場合は、 UpdateClusterSoftwareオペレーションを使用して、 ImageIdフィールドにカスタム AMI を指定できます。リクエストで特定のインスタンスグループの名前を指定しない限り、新しいイメージはクラスター内のすべてのインスタンスグループに適用されます。

次の例は、カスタム AMI を使用してクラスターのプラットフォームソフトウェアを更新する方法を示しています。

aws sagemaker update-cluster-software \ --cluster-name <exampleClusterName> \ --instance-groups <instanceGroupToUpdate> \ --image-id <customAmiId>

インスタンスグループのスケールアップ

次の例は、カスタム AMI を使用してクラスターのインスタンスグループをスケールアップする方法を示しています。

aws sagemaker update-cluster \ --cluster-name <exampleClusterName> --instance-groups '[{ "InstanceGroupName": "<exampleGroupName>", "InstanceType": "ml.c5.2xlarge", "InstanceCount": 2, "LifeCycleConfig": { "SourceS3Uri": "<s3://amzn-s3-demo-bucket>", "OnCreate": "on_create_noop.sh" }, "ExecutionRole": "<arn:aws:iam::444455556666:role/Admin>", "ThreadsPerCore": 1, "ImageId": "<your_custom_ami>" }]'

インスタンスグループを追加する

次の例は、カスタム AMI を使用してインスタンスグループをクラスターに追加する方法を示しています。

aws sagemaker update-cluster \ --cluster-name "<exampleClusterName>" \ --instance-groups '{ "InstanceGroupName": "<exampleGroupName>", "InstanceType": "ml.c5.2xlarge", "InstanceCount": 2, "LifeCycleConfig": { "SourceS3Uri": "<s3://amzn-s3-demo-bucket>", "OnCreate": "on_create_noop.sh" }, "ExecutionRole": "<arn:aws:iam::444455556666:role/Admin>", "ThreadsPerCore": 1, "ImageId": "<your_custom_ami>" }' '{ "InstanceGroupName": "<exampleGroupName2>", "InstanceType": "ml.c5.2xlarge", "InstanceCount": 1, "LifeCycleConfig": { "SourceS3Uri": "<s3://amzn-s3-demo-bucket>", "OnCreate": "on_create_noop.sh" }, "ExecutionRole": "<arn:aws:iam::444455556666:role/Admin>", "ThreadsPerCore": 1, "ImageId": "<your_custom_ami>" }'