清理映像资源 - Amazon SageMaker
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

清理映像资源

本指南介绍如何清理您在前面部分中创建的 RStudio 映像资源。要删除图像,请使用 SageMaker 控制台或本指南中所示完成以下步骤。 Amazon CLI

  • 将图片和图片版本与您的 Amazon SageMaker 域名分离。

  • 删除映像、映像版本和应用程序映像配置。

完成这些步骤后,您可以从 Amazon ECR 中删除容器映像和存储库。有关如何删除容器映像和存储库的更多信息,请参阅删除存储库

从 SageMaker控制台清理资源

从域中分离映像时,将分离该映像的所有版本。分离映像后,域的所有用户都将失去对映像版本的访问权限。

分离映像
  1. 打开亚马逊 SageMaker 控制台,网址为 https://console.aws.amazon.com/sagemaker/

  2. 在左侧导航窗格中,选择管理员配置

  3. 管理员配置下,选择

  4. 选择所需的域。

  5. 选择环境

  6. 附加到域的自定义映像下,选择映像,然后选择分离

  7. (可选)要删除图像和所有版本 SageMaker,请选择同时删除所选图像... 。这不会从 Amazon ECR 中删除关联的映像。

  8. 选择分离

通过 Amazon CLI清理资源

清理资源
  1. 通过向域传递一个空的自定义映像列表,将映像和映像版本从域中分离。打开在 将 SageMaker 图片附加到您当前的域名 中创建的 update-domain-input.json 文件。

  2. 删除 RSessionAppSettings 自定义映像,然后保存文件。请勿修改 KernelGatewayAppSettings 自定义映像。

    { "DomainId": "d-xxxxxxxxxxxx", "DefaultUserSettings": { "KernelGatewayAppSettings": { "CustomImages": [ ], ... }, "RSessionAppSettings": { "CustomImages": [ ], "DefaultResourceSpec": { } ... } } }
  3. 使用域 ID 和默认用户设置文件更新域。

    aws sagemaker update-domain \ --domain-id <d-xxxxxxxxxxxx> \ --cli-input-json file://update-domain-input.json

    响应:

    { "DomainArn": "arn:aws:sagemaker:us-east-2:acct-id:domain/d-xxxxxxxxxxxx" }
  4. 删除应用程序映像配置。

    aws sagemaker delete-app-image-config \ --app-image-config-name rstudio-image-config
  5. 删除 SageMaker 图像,这也会删除所有图像版本。Amazon ECR 中由映像版本表示的容器映像不会被删除。

    aws sagemaker delete-image \ --image-name rstudio-image