Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门。本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
删除终端节点和资源
删除终端节点以停止产生费用。
删除端节点
使用以编程方式删除终端节点Amazon SDK for Python (Boto3),使用Amazon CLI,或者以交互方式使用 SageMaker 控制台。
SageMaker 释放在创建终端节点时部署的所有资源。删除终端节点不会删除终端节点配置或 SageMaker 模型。请参阅删除端点配置和删除模型了解有关如何删除终端节点配置的信息以及 SageMaker 模型。
- Amazon 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)
- Amazon CLI
使用delete-endpoint命令删除终端节点。将终端节点的名称指定为endpoint-name标记。
aws sagemaker delete-endpoint --endpoint-name <endpoint-name>
- SageMaker Console
-
使用以交互方式删除终端节点 SageMaker 控制台。
删除端点配置
使用以编程方式删除终端节点配置Amazon SDK for Python (Boto3),使用Amazon CLI,或者以交互方式使用 SageMaker 控制台。删除终端节点配置不会删除使用此配置创建的终端节点。请参阅删除端节点有关如何删除终端节点的信息。
请勿删除处于活动状态的终端节点或正在更新或创建终端节点时使用的终端节点配置。如果删除处于活动状态或正在创建或更新的终端节点的终端节点配置,则可能无法了解终端节点正在使用的实例类型。
- Amazon 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,请参阅DescribeEndpointConfig中的SageMaker API 参考指南.
- Amazon CLI
使用delete-endpoint-config命令删除终端节点配置。将终端节点配置的名称指定为endpoint-config-name标记。
aws sagemaker delete-endpoint-config \
--endpoint-config-name <endpoint-config-name>
您可以选择使用describe-endpoint-config命令返回有关已部署模型(生产变体)名称的信息,例如模型的名称以及与该已部署模型关联的终端节点配置的名称。提供终端节点的名称,以供endpoint-config-name标记。
aws sagemaker describe-endpoint-config --endpoint-config-name <endpoint-config-name>
这将返回 JSON 响应。您可以复制和粘贴、使用 JSON 解析器或使用为 JSON 解析而构建的工具来获取与该终端节点关联的终端节点配置名称。
- SageMaker Console
-
使用以交互方式删除终端节点配置 SageMaker 控制台。
删除模型
删除您的 SageMaker 使用编程方式使用Amazon SDK for Python (Boto3),使用Amazon CLI,或者以交互方式使用 SageMaker 控制台。删除集群 SageMaker 模型仅删除在 SageMaker 中创建的模型条目。删除模型不会删除模型构件、推理代码或在创建模型时指定的 IAM 角色。
- Amazon SDK for Python (Boto3)
使用DeleteModel用于删除你的 API 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,请参阅DescribeEndpointConfig中的SageMaker API 参考指南.
- Amazon CLI
使用delete-model命令删除 SageMaker 模型。对于,请指定模型的名称model-name标记。
aws sagemaker delete-model \
--model-name <model-name>
您可以选择使用describe-endpoint-config命令返回有关已部署模型(生产变体)名称的信息,例如模型的名称以及与该已部署模型关联的终端节点配置的名称。提供终端节点的名称,以供endpoint-config-name标记。
aws sagemaker describe-endpoint-config --endpoint-config-name <endpoint-config-name>
这将返回 JSON 响应。您可以复制和粘贴、使用 JSON 解析器或使用为 JSON 解析而构建的工具来获取与该终端节点关联的模型的名称。
- SageMaker Console
-
删除您的 SageMaker 以交互方式建模 SageMaker 控制台。