

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# エンドポイントとリソースを削除する
<a name="realtime-endpoints-delete-resources"></a>

エンドポイントを削除して料金の発生を停止します。

## エンドポイントを削除する
<a name="realtime-endpoints-delete-endpoint"></a>

を使用してプログラムで AWS SDK for Python (Boto3)、 を使用して AWS CLI、または SageMaker AI コンソールを使用してインタラクティブにエンドポイントを削除します。

SageMaker AI は、エンドポイントの作成時にデプロイされたすべてのリソースを解放します。エンドポイントを削除しても、エンドポイント設定や SageMaker AI モデルは削除されません。エンドポイント設定と SageMaker AI モデルを削除する方法については、「[エンドポイント設定を削除する](#realtime-endpoints-delete-endpoint-config)」および「[モデルを削除する](#realtime-endpoints-delete-model)」を参照してください。

------
#### [ AWS SDK for Python (Boto3) ]

[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. [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/) ナビゲーションメニューの SageMaker AI コンソールで、**[推論]** を選択します。

1. ドロップダウンメニューから **[エンドポイント]** を選択します。 AWS アカウントで作成されたエンドポイントのリストは、名前、Amazon リソースネーム (ARN)、作成時刻、ステータス、エンドポイントが最後に更新された時刻のタイムスタンプで表示されます。

1. 削除するエンドポイントを選択します。

1. 右上隅にある **[アクション]** ドロップダウンボタンを選択します。

1. **[削除]** を選択します。

------

## エンドポイント設定を削除する
<a name="realtime-endpoints-delete-endpoint-config"></a>

を使用してプログラムで AWS SDK for Python (Boto3)、 を使用して AWS CLI、または SageMaker AI コンソールを使用してインタラクティブにエンドポイント設定を削除します。エンドポイント設定を削除しても、その設定を使用して作成されたエンドポイントは削除されません。エンドポイントを削除する方法については、「[エンドポイントを削除する](#realtime-endpoints-delete-endpoint)」を参照してください。

有効なエンドポイント、またはエンドポイントが更新または作成されている間は、使用中のエンドポイント設定を削除しないでください。アクティブまたは作成または更新中のエンドポイントのエンドポイント設定を削除すると、エンドポイントが使用しているインスタンスタイプが見えなくなる可能性があります。

------
#### [ AWS SDK for Python (Boto3) ]

[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_Operations_Amazon_SageMaker_Service.html)」の「[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.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. [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/) ナビゲーションメニューの SageMaker AI コンソールで、**[推論]** を選択します。

1. ドロップダウンメニューから **[エンドポイント設定]** を選択します。 AWS アカウントで作成されたエンドポイント設定のリストは、名前、Amazon リソースネーム (ARN)、および作成時間別に表示されます。

1. 削除するエンドポイント設定を選択します。

1. 右上隅にある **[アクション]** ドロップダウンボタンを選択します。

1. **[削除]** を選択します。

------

## モデルを削除する
<a name="realtime-endpoints-delete-model"></a>

、 AWS SDK for Python (Boto3)、または SageMaker AI コンソールを使用してインタラクティブに AWS CLIプログラムで SageMaker AI モデルを削除します。SageMaker AI モデルを削除すると、SageMaker AI で作成されたモデルエントリのみが削除されます。モデルを削除しても、モデルアーティファクト、推論コード、モデル作成時に指定した IAM ロールは削除されません。

------
#### [ AWS SDK for Python (Boto3) ]

[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_Operations_Amazon_SageMaker_Service.html)」の「[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.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 コンソールを使用してインタラクティブに SageMaker AI モデルを削除します。

1. [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/) ナビゲーションメニューの SageMaker AI コンソールで、**[推論]** を選択します。

1. ドロップダウンメニューから **[モデル]** を選択します。 AWS アカウントで作成されたモデルのリストは、名前、Amazon リソースネーム (ARN)、および作成時刻で表示されます。

1. 削除するモデルを選択します。

1. 右上隅にある **[アクション]** ドロップダウンボタンを選択します。

1. **[Delete]** (削除) をクリックします。

------