Clean up 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.
The following sections show how to clean up the resources you created in the previous sections from the SageMaker console or AWS CLI. You perform the following steps to clean up the resources:
Detach the image and image versions from your domain.
Delete the image, image version, and app image config.
Delete the container image and repository from Amazon ECR. For more information, see Deleting a repository.
Clean up resources from the SageMaker console
The following section shows how to clean up resources from the SageMaker console.
When you detach an image from a domain, all versions of the image are detached. When an image is detached, all users of the domain lose access to the image versions. A running notebook that has a kernel session on an image version when the version is detached, continues to run. When the notebook is stopped or the kernel is shut down, the image version becomes unavailable.
To detach an image
-
Open the Amazon SageMaker console at https://console.aws.amazon.com/sagemaker/
. -
On the left navigation pane, choose Admin configurations.
-
Under Admin configurations, choose Images.
-
Under Custom SageMaker Studio Classic images attached to domain, choose the image and then choose Detach.
-
(Optional) To delete the image and all versions from SageMaker, select Also delete the selected images .... This does not delete the associated container images from Amazon ECR.
-
Choose Detach.
Clean up resources from the AWS CLI
The following section shows how to clean up resources from the AWS CLI.
To clean up resources
-
Detach the image and image versions from your domain by passing an empty custom image list to the domain. Open the
default-user-settings.json
file you created in Attach the SageMaker image to your current domain. To detach the image and image version from a shared space, open thedefault-space-settings.json
file. -
Delete the custom images and then save the file.
"DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... }, ... }
-
Use the domain ID and default user settings file to update your domain. To update your shared space, use the default space settings file.
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" }
-
Delete the app image config.
aws sagemaker delete-app-image-config \ --app-image-config-name custom-image-config
-
Delete the SageMaker image, which also deletes all image versions. The container images in ECR that are represented by the image versions are not deleted.
aws sagemaker delete-image \ --image-name custom-image