Attach a custom SageMaker AI image
Important
Custom IAM policies that allow Amazon SageMaker Studio or Amazon SageMaker Studio Classic to create Amazon SageMaker resources must also grant permissions to add tags to those resources. The permission to add tags to resources is required because Studio and Studio Classic automatically tag any resources they create. If an IAM policy allows Studio and Studio Classic to create resources but does not allow tagging, "AccessDenied" errors can occur when trying to create resources. For more information, see Provide permissions for tagging SageMaker AI resources.
AWS managed policies for Amazon SageMaker AI that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.
Important
As of November 30, 2023, the previous Amazon SageMaker Studio experience is now named Amazon SageMaker Studio Classic. The following section is specific to using the Studio Classic application. For information about using the updated Studio experience, see Amazon SageMaker Studio.
To use a custom SageMaker AI image, you must attach a version of the image to your domain or shared space. When you attach an image version, it appears in the SageMaker Studio Classic Launcher and is available in the Select image dropdown list, which users use to launch an activity or change the image used by a notebook.
To make a custom SageMaker AI image available to all users within a domain, you attach the image to the domain. To make an image available to all users within a shared space, you can attach the image to the shared space. To make an image available to a single user, you attach the image to the user's profile. When you attach an image, SageMaker AI uses the latest image version by default. You can also attach a specific image version. After you attach the version, you can choose the version from the SageMaker AI Launcher or the image selector when you launch a notebook.
There is a limit to the number of image versions that can be attached at any given time. After you reach the limit, you must detach a version in order to attach another version of the image.
The following sections demonstrate how to attach a custom SageMaker AI image to your domain using either the SageMaker AI console or the AWS CLI. You can only attach a custom image to a share space using the AWS CLI.
Attach the SageMaker AI image to a domain
Attach the SageMaker AI image using the Console
This topic describes how you can attach an existing custom SageMaker AI image version to your domain using the SageMaker AI control panel. You can also create a custom SageMaker AI image and image version, and then attach that version to your domain. For the procedure to create an image and image version, see Create a custom SageMaker AI image.
To attach an existing image
-
Open the Amazon SageMaker AI console at https://console.aws.amazon.com/sagemaker/
. -
On the left navigation pane, choose Admin configurations.
-
Under Admin configurations, choose domains.
-
From the Domains page, select the domain to attach the image to.
-
From the Domain details page, select the Environment tab.
-
On the Environment tab, under Custom SageMaker Studio Classic images attached to domain, choose Attach image.
-
For Image source, choose Existing image.
-
Choose an existing image from the list.
-
Choose a version of the image from the list.
-
Choose Next.
-
Verify the values for Image name, Image display name, and Description.
-
Choose the IAM role. For more information, see Create a custom SageMaker AI image.
-
(Optional) Add tags for the image.
-
Specify the EFS mount path. This is the path within the image to mount the user's Amazon Elastic File System (EFS) home directory.
-
For Image type, select SageMaker Studio image
-
For Kernel name, enter the name of an existing kernel in the image. For information on how to get the kernel information from the image, see DEVELOPMENT
in the SageMaker Studio Classic Custom Image Samples repository. For more information, see the Kernel discovery and User data sections of Custom SageMaker AI image specifications. -
(Optional) For Kernel display name, enter the display name for the kernel.
-
Choose Add kernel.
-
Choose Submit.
Wait for the image version to be attached to the domain. When attached, the version is displayed in the Custom images list and briefly highlighted.
Attach the SageMaker AI image using the AWS CLI
The following sections demonstrate how to attach a custom SageMaker AI image when creating a new domain or updating your existing domain using the AWS CLI.
Attach the SageMaker AI image to a new domain
The following section demonstrates how to create a new domain with the version attached. These steps require that you specify the Amazon Virtual Private Cloud (VPC) information and execution role required to create the domain. You perform the following steps to create the domain and attach the custom SageMaker AI image:
Get your default VPC ID and subnet IDs.
Create the configuration file for the domain, which specifies the image.
Create the domain with the configuration file.
To add the custom SageMaker AI image to your domain
-
Get your default VPC ID.
aws ec2 describe-vpcs \ --filters Name=isDefault,Values=true \ --query "Vpcs[0].VpcId" --output text
The response should look similar to the following.
vpc-xxxxxxxx
-
Get your default subnet IDs using the VPC ID from the previous step.
aws ec2 describe-subnets \ --filters Name=vpc-id,Values=
<vpc-id>
\ --query "Subnets[*].SubnetId" --output jsonThe response should look similar to the following.
[ "subnet-b55171dd", "subnet-8a5f99c6", "subnet-e88d1392" ]
-
Create a configuration file named
create-domain-input.json
. Insert the VPC ID, subnet IDs,ImageName
, andAppImageConfigName
from the previous steps. BecauseImageVersionNumber
isn't specified, the latest version of the image is used, which is the only version in this case.{ "DomainName": "domain-with-custom-image", "VpcId": "
<vpc-id>
", "SubnetIds": [ "<subnet-ids>
" ], "DefaultUserSettings": { "ExecutionRole": "<execution-role>
", "KernelGatewayAppSettings": { "CustomImages": [ { "ImageName": "custom-image", "AppImageConfigName": "custom-image-config" } ] } }, "AuthMode": "IAM" } -
Create the domain with the attached custom SageMaker AI image.
aws sagemaker create-domain \ --cli-input-json file://create-domain-input.json
The response should look similar to the following.
{ "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx", "Url": "https://d-xxxxxxxxxxxx.studio.us-east-2.sagemaker.aws/..." }
Attach the SageMaker AI image to your current domain
If you have onboarded to a SageMaker AI domain, you can attach the custom image to your current domain. For more information about onboarding to a SageMaker AI domain, see Amazon SageMaker AI domain overview. You don't need to specify the VPC information and execution role when attaching a custom image to your current domain. After you attach the version, you must delete all the apps in your domain and reopen Studio Classic. For information about deleting the apps, see Delete an Amazon SageMaker AI domain.
You perform the following steps to add the SageMaker AI image to your current domain.
Get your
DomainID
from SageMaker AI control panel.Use the
DomainID
to get theDefaultUserSettings
for the domain.Add the
ImageName
andAppImageConfig
as aCustomImage
to theDefaultUserSettings
.Update your domain to include the custom image.
To add the custom SageMaker AI image to your domain
-
Open the Amazon SageMaker AI console at https://console.aws.amazon.com/sagemaker/
. -
On the left navigation pane, choose Admin configurations.
-
Under Admin configurations, choose domains.
-
From the Domains page, select the domain to attach the image to.
-
From the Domain details page, select the Domain settings tab.
-
From the Domain settings tab, under General settings, find the
DomainId
. The ID is in the following format:d-xxxxxxxxxxxx
. -
Use the domain ID to get the description of the domain.
aws sagemaker describe-domain \ --domain-id
<d-xxxxxxxxxxxx>
The response should look similar to the following.
{ "DomainId": "d-xxxxxxxxxxxx", "DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... } } }
-
Save the default user settings section of the response to a file named
default-user-settings.json
. -
Insert the
ImageName
andAppImageConfigName
from the previous steps as a custom image. BecauseImageVersionNumber
isn't specified, the latest version of the image is used, which is the only version in this case.{ "DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ { "ImageName": "string", "AppImageConfigName": "string" } ], ... } } }
-
Use the domain ID and default user settings file to update your domain.
aws sagemaker update-domain \ --domain-id
<d-xxxxxxxxxxxx>
\ --cli-input-json file://default-user-settings.jsonThe response should look similar to the following.
{ "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx" }
Attach the SageMaker AI image to a shared space
You can only attach the SageMaker AI image to a shared space using the AWS CLI. After you attach the version, you must delete all of the applications in your shared space and reopen Studio Classic. For information about deleting the apps, see Delete an Amazon SageMaker AI domain.
You perform the following steps to add the SageMaker AI image to a shared space.
Get your
DomainID
from SageMaker AI control panel.Use the
DomainID
to get theDefaultSpaceSettings
for the domain.Add the
ImageName
andAppImageConfig
as aCustomImage
to theDefaultSpaceSettings
.Update your domain to include the custom image for the shared space.
To add the custom SageMaker AI image to your shared space
-
Open the Amazon SageMaker AI console at https://console.aws.amazon.com/sagemaker/
. -
On the left navigation pane, choose Admin configurations.
-
Under Admin configurations, choose domains.
-
From the Domains page, select the domain to attach the image to.
-
From the Domain details page, select the Domain settings tab.
-
From the Domain settings tab, under General settings, find the
DomainId
. The ID is in the following format:d-xxxxxxxxxxxx
. -
Use the domain ID to get the description of the domain.
aws sagemaker describe-domain \ --domain-id
<d-xxxxxxxxxxxx>
The response should look similar to the following.
{ "DomainId": "d-xxxxxxxxxxxx", ... "DefaultSpaceSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... } } }
-
Save the default space settings section of the response to a file named
default-space-settings.json
. -
Insert the
ImageName
andAppImageConfigName
from the previous steps as a custom image. BecauseImageVersionNumber
isn't specified, the latest version of the image is used, which is the only version in this case.{ "DefaultSpaceSettings": { "KernelGatewayAppSettings": { "CustomImages": [ { "ImageName": "string", "AppImageConfigName": "string" } ], ... } } }
-
Use the domain ID and default space settings file to update your domain.
aws sagemaker update-domain \ --domain-id
<d-xxxxxxxxxxxx>
\ --cli-input-json file://default-space-settings.jsonThe response should look similar to the following.
{ "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx" }
View the attached image in SageMaker AI
After you create the custom SageMaker AI image and attach it to your domain, the image appears in the Environment tab of the domain. You can only view the attached images for shared spaces using the AWS CLI by using the following command.
aws sagemaker describe-domain \ --domain-id
<d-xxxxxxxxxxxx>