

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

# 删除端点和资源
<a name="realtime-endpoints-delete-resources"></a>

删除端点以停止产生费用。

## 删除端点
<a name="realtime-endpoints-delete-endpoint"></a>

使用、通过 AI 控制台以编程方式删除您的终端节点 适用于 Python (Boto3) 的 AWS SDK AWS CLI，或者使用 SageMaker AI 控制台以交互方式删除您的终端节点。

SageMaker AI 可以释放创建终端节点时部署的所有资源。删除终端节点不会删除终端节点配置或 SageMaker AI 模型。有关如何删除终端节点配置和 SageMaker AI 模型的信息，请参阅[删除端点配置](#realtime-endpoints-delete-endpoint-config)和。[删除模型](#realtime-endpoints-delete-model)

------
#### [ 适用于 Python (Boto3) 的 AWS SDK ]

使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteEndpoint.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteEndpoint.html) 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 ]

使用 [https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-endpoint.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-endpoint.html) 命令删除端点。为 `endpoint-name` 标志指定端点的名称。

```
aws sagemaker delete-endpoint --endpoint-name <endpoint-name>
```

------
#### [ SageMaker AI Console ]

使用 SageMaker AI 控制台以交互方式删除您的终端节点。

1. 在 SageMaker AI 控制台的[https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)导航菜单中，选择**推理**。

1. 从下拉菜单中选择**端点**。在您的 AWS 账户中创建的终端节点列表将按名称、Amazon 资源名称 (ARN)、创建时间、状态和上次更新终端节点的时间戳显示。

1. 选择要删除的端点。

1. 选择右上角的**操作**下拉按钮。

1. 选择**删除**。

------

## 删除端点配置
<a name="realtime-endpoints-delete-endpoint-config"></a>

使用 AI 控制台、通过编程方式删除您的终端节点配置 适用于 Python (Boto3) 的 AWS SDK，或者使用 AI 控制台以 AWS CLI交互方式删除您的终端节点配置。 SageMaker 删除端点配置不会删除使用此配置创建的端点。有关如何删除端点的信息，请参阅[删除端点](#realtime-endpoints-delete-endpoint)。

请不要删除处于活动状态的端点所使用的端点配置，也不要删除正在更新或创建的端点所用的端点配置。如果您删除处于活动状态或者正在创建或更新的端点的端点配置，那么可能会失去对端点正在使用的实例类型的可见性。

------
#### [ 适用于 Python (Boto3) 的 AWS SDK ]

使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteEndpointConfig.html) 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)
```

您可以选择使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html) 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 参考指南[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html)](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_Operations_Amazon_SageMaker_Service.html)中的。

------
#### [ AWS CLI ]

使用 [https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-endpoint-config.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-endpoint-config.html) 命令删除端点配置。为 `endpoint-config-name` 标志指定端点配置的名称。

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

您可以选择使用 [https://docs.aws.amazon.com/cli/latest/reference/sagemaker/describe-endpoint-config.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/describe-endpoint-config.html) 命令返回有关已部署模型（生产变体）名称的信息，例如，模型的名称以及与该已部署模型关联的端点配置的名称。为 `endpoint-config-name` 标志提供端点的名称。

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

此命令将返回 JSON 响应。您可以通过复制和粘贴、使用 JSON 解析器或者针对 JSON 解析构建的工具，获取与该端点关联的端点配置名称。

------
#### [ SageMaker AI Console ]

使用 SageMaker AI 控制台以交互方式删除您的终端节点配置。

1. 在 SageMaker AI 控制台的[https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)导航菜单中，选择**推理**。

1. 从下拉菜单中选择**端点配置**。在 AWS 账户中创建的端点配置列表将按名称、Amazon 资源名称 (ARN) 和创建时间显示。

1. 选择要删除的端点配置。

1. 选择右上角的**操作**下拉按钮。

1. 选择**删除**。

------

## 删除模型
<a name="realtime-endpoints-delete-model"></a>

使用 SageMaker AI 控制台以编程方式删除 AI 模型 适用于 Python (Boto3) 的 AWS SDK，或者使用 AI 控制台以 AWS CLI交互方式删除 AI 模型。 SageMaker 删除 A SageMaker I 模型只会删除在 A SageMaker I 中创建的模型条目。删除模型不会删除模型构件、推理代码或在创建模型时指定的 IAM 角色。

------
#### [ 适用于 Python (Boto3) 的 AWS SDK ]

使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteModel.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteModel.html)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)
```

您可以选择使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html) 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 参考指南[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html)](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_Operations_Amazon_SageMaker_Service.html)中的。

------
#### [ AWS CLI ]

使用[https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-model.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/delete-model.html)命令删除您的 SageMaker AI 模型。为 `model-name` 标志指定模型的名称。

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

您可以选择使用 [https://docs.aws.amazon.com/cli/latest/reference/sagemaker/describe-endpoint-config.html](https://docs.aws.amazon.com/cli/latest/reference/sagemaker/describe-endpoint-config.html) 命令返回有关已部署模型（生产变体）名称的信息，例如，模型的名称以及与该已部署模型关联的端点配置的名称。为 `endpoint-config-name` 标志提供端点的名称。

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

此命令将返回 JSON 响应。您可以通过复制和粘贴、使用 JSON 解析器或者针对 JSON 解析构建的工具，获取与该端点关联的模型名称。

------
#### [ SageMaker AI Console ]

使用 SageMaker AI 控制台以交互方式删除您的 A SageMaker I 模型。

1. 在 SageMaker AI 控制台的[https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/)导航菜单中，选择**推理**。

1. 从下拉菜单中选择**模型**。在您的 AWS 账户中创建的模型列表将按名称、Amazon 资源名称 (ARN) 和创建时间显示。

1. 选择要删除的模型。

1. 选择右上角的**操作**下拉按钮。

1. 选择**删除**。

------