刪除端點和資源 - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

刪除端點和資源

刪除端點,停止產生費用。

刪除端點

使用 適用於 Python (Boto3) 的 AWS SDK、 搭配 以程式設計方式刪除端點 AWS CLI,或使用 SageMaker AI 主控台以互動方式刪除端點。

SageMaker AI 會釋放建立端點時部署的所有資源。刪除端點並不會刪除端點組態或 SageMaker AI 模型。如需有關如何刪除端點組態和 SageMaker AI 模型的資訊,請參閱刪除端點組態刪除模型

適用於 Python (Boto3) 的 AWS SDK

使用 DeleteEndpoint API 刪除端點。為 EndpointName 欄位指定端點名稱。

import boto3 # Specify your AWS Region aws_region='<aws_region>' # Specify the name of your endpoint endpoint_name='<endpoint_name>' # Create a low-level SageMaker service client. sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # Delete endpoint sagemaker_client.delete_endpoint(EndpointName=endpoint_name)
AWS CLI

若要刪除端點,請使用 delete-endpoint 命令。為 endpoint-name 旗標指定端點名稱。

aws sagemaker delete-endpoint --endpoint-name <endpoint-name>
SageMaker AI Console

使用 SageMaker AI 主控台以互動方式刪除端點。

  1. 在位於 https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker AI 主控台,選擇推論

  2. 從下拉式功能表選擇端點。在您的 AWS 帳戶中建立的端點清單會依名稱、Amazon Resource Name (ARN)、建立時間、狀態和上次更新端點時的時間戳記顯示。

  3. 選取您要刪除的端點。

  4. 選取右上角的動作下拉式按鈕。

  5. 選擇刪除

刪除端點組態

使用 適用於 Python (Boto3) 的 AWS SDK、 搭配 以程式設計方式刪除端點組態 AWS CLI,或使用 SageMaker AI 主控台以互動方式刪除端點組態。刪除端點組態並不會刪除使用這個組態建立的端點。如需如何刪除端點的資訊,請參閱刪除端點

請勿刪除作用中端點正在使用的端點組態,也不要在端點更新或建立時刪除端點組態。如果刪除作用中或正在建立或更新之端點的端點組態,可能會失去對端點使用中執行個體類型的可見度。

適用於 Python (Boto3) 的 AWS SDK

使用 DeleteEndpointConfig API 刪除端點。為 EndpointConfigName 欄位指定端點組態名稱。

import boto3 # Specify your AWS Region aws_region='<aws_region>' # Specify the name of your endpoint configuration endpoint_config_name='<endpoint_name>' # Create a low-level SageMaker service client. sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # Delete endpoint configuration sagemaker_client.delete_endpoint_config(EndpointConfigName=endpoint_config_name)

您可以選擇使用 DescribeEndpointConfig API 傳回已部署模型 (生產變體) 名稱的相關資訊,例如模型名稱,以及與該部署模型相關的端點組態名稱。為 EndpointConfigName 欄位提供端點名稱。

# Specify the name of your endpoint endpoint_name='<endpoint_name>' # Create a low-level SageMaker service client. sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # Store DescribeEndpointConfig response into a variable that we can index in the next step. response = sagemaker_client.describe_endpoint_config(EndpointConfigName=endpoint_name) # Delete endpoint endpoint_config_name = response['ProductionVariants'][0]['EndpointConfigName'] # Delete endpoint configuration sagemaker_client.delete_endpoint_config(EndpointConfigName=endpoint_config_name)

如需 DescribeEndpointConfig 傳回之其他回應元素的詳細資訊,請參閱 SageMaker API 參考指南DescribeEndpointConfig

AWS CLI

若要刪除端點組態,請使用 delete-endpoint-config 命令。為 endpoint-config-name 旗幟指定端點組態名稱。

aws sagemaker delete-endpoint-config \ --endpoint-config-name <endpoint-config-name>

您可以選擇使用 describe-endpoint-config API 命令傳回已部署模型 (生產變體) 名稱的相關資訊,例如模型名稱,以及與該部署模型相關的端點組態名稱。為 endpoint-config-name 旗標提供端點名稱。

aws sagemaker describe-endpoint-config --endpoint-config-name <endpoint-config-name>

隨即會傳回 JSON 回應。您可以複製貼上、使用 JSON 剖析器,或使用專為 JSON 剖析而建置的工具,取得與該端點相關的端點組態名稱。

SageMaker AI Console

使用 SageMaker AI 主控台以互動方式刪除端點組態。

  1. 在位於 https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker AI 主控台,選擇推論

  2. 從下拉式功能表選擇端點組態。 AWS 帳戶建立的端點組態清單會依名稱、Amazon Resource Name (ARN) 和建立時間顯示。

  3. 選取您要刪除的端點組態。

  4. 選取右上角的動作下拉式按鈕。

  5. 選擇刪除

刪除模型

使用 適用於 Python (Boto3) 的 AWS SDK、 搭配 以程式設計方式刪除 SageMaker AI 模型 AWS CLI,或使用 SageMaker AI 主控台以互動方式刪除 SageMaker AI 模型。刪除 SageMaker AI 模型只會刪除在 SageMaker AI 建立的模型項目。刪除模型不會刪除模型成品、推論程式碼,或您在建立模型時指定的 IAM 角色。

適用於 Python (Boto3) 的 AWS SDK

使用 DeleteModel API 刪除 SageMaker AI 模型。為 ModelName 欄位指定模型名稱。

import boto3 # Specify your AWS Region aws_region='<aws_region>' # Specify the name of your endpoint configuration model_name='<model_name>' # Create a low-level SageMaker service client. sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # Delete model sagemaker_client.delete_model(ModelName=model_name)

您可以選擇使用 DescribeEndpointConfig API 傳回已部署模型 (生產變體) 名稱的相關資訊,例如模型名稱,以及與該部署模型相關的端點組態名稱。為 EndpointConfigName 欄位提供端點名稱。

# Specify the name of your endpoint endpoint_name='<endpoint_name>' # Create a low-level SageMaker service client. sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # Store DescribeEndpointConfig response into a variable that we can index in the next step. response = sagemaker_client.describe_endpoint_config(EndpointConfigName=endpoint_name) # Delete endpoint model_name = response['ProductionVariants'][0]['ModelName'] sagemaker_client.delete_model(ModelName=model_name)

如需 DescribeEndpointConfig 傳回之其他回應元素的詳細資訊,請參閱 SageMaker API 參考指南DescribeEndpointConfig

AWS CLI

使用 delete-model 命令刪除 SageMaker AI 模型。為 model-name 旗標指定模型名稱。

aws sagemaker delete-model \ --model-name <model-name>

您可以選擇使用 describe-endpoint-config API 命令傳回已部署模型 (生產變體) 名稱的相關資訊,例如模型名稱,以及與該部署模型相關的端點組態名稱。為 endpoint-config-name 旗標提供端點名稱。

aws sagemaker describe-endpoint-config --endpoint-config-name <endpoint-config-name>

隨即會傳回 JSON 回應。您可以複製貼上、使用 JSON 剖析器,或使用專為 JSON 剖析而建置的工具,取得與該端點相關的模型名稱。

SageMaker AI Console

使用 SageMaker AI 主控台以互動方式刪除 SageMaker AI 模型。

  1. 在位於 https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker AI 主控台,選擇推論

  2. 從下拉式功能表選擇模型。在您 AWS 帳戶中建立的模型清單會依名稱、Amazon Resource Name (ARN) 和建立時間顯示。

  3. 選取您要刪除的模型。

  4. 選取右上角的動作下拉式按鈕。

  5. 選擇刪除