刪除端點和資源 - Amazon SageMaker

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

刪除端點和資源

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

刪除端點

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

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

AWS SDK for Python (Boto3)

使用 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 Console

透過 SageMaker 主控台以互動方式刪除端點。

  1. https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker 主控台中,選擇「推論」。

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

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

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

  5. 選擇刪除

刪除端點組態

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

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

AWS SDK for Python (Boto3)

使用 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 Console

透過 SageMaker主控台以互動方式刪除端點設定。

  1. https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker 主控台中,選擇「推論」。

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

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

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

  5. 選擇刪除

刪除模型

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

AWS SDK for Python (Boto3)

使用 DeleteModelAPI 刪除您的 SageMaker 模型。為 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模型。為 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 Console

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

  1. https://console.aws.amazon.com/sagemaker/ 瀏覽功能表的 SageMaker 主控台中,選擇「推論」。

  2. 從下拉式功能表選擇模型。您 AWS 帳戶中創建的模型列表將按名稱,Amazon 資源名稱(ARN)和創建時間顯示。

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

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

  5. 選擇 刪除