

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

# 刪除自訂模型部署
<a name="delete-custom-model-deployment"></a>

使用模型完成隨需推論後，您可以刪除部署。刪除部署後，您便無法將其用於隨需推論，但不會刪除基礎自訂模型。

您可以使用 Amazon Bedrock 主控台 AWS Command Line Interface或 AWS SDKs 刪除自訂模型部署。

**重要**  
刪除自訂模型部署是不可復原的。在繼續刪除之前，請確定您不再需要部署。如果您需要再次使用自訂模型進行隨需推論，則必須建立新的部署。

**Topics**
+ [刪除自訂模型部署 (主控台)](#delete-deployment-console)
+ [刪除自訂模型部署 (AWS Command Line Interface)](#delete-deployment-cli)
+ [刪除自訂模型部署AWS SDKs)](#delete-deployment-sdk)

## 刪除自訂模型部署 (主控台)
<a name="delete-deployment-console"></a>

**刪除自訂模型部署**

1. 在導覽窗格的**推論和評估**下，選擇**隨需自訂模型**。

1. 選擇您要刪除的自訂模型部署。

1. 選擇**刪除**。

1. 在確認對話方塊中，輸入部署名稱以確認刪除。

1. 選擇**刪除**以確認刪除。

當刪除正在進行時，部署狀態會變更為 `Deleting`。完成後，部署將從清單中移除。

## 刪除自訂模型部署 (AWS Command Line Interface)
<a name="delete-deployment-cli"></a>

若要使用 刪除自訂模型部署 AWS Command Line Interface，請使用 `delete-custom-model-deployment`命令搭配您的部署識別符。

```
aws bedrock delete-custom-model-deployment \
--custom-model-deployment-identifier "deployment-arn-or-name" \
--region region
```

## 刪除自訂模型部署AWS SDKs)
<a name="delete-deployment-sdk"></a>

若要以程式設計方式刪除自訂模型部署，請使用 [DeleteCustomModelDeployment](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_DeleteCustomModelDeployment.html) API 操作搭配部署的 Amazon Resource Name (ARN) 或名稱。下列程式碼說明如何使用適用於 Python (Boto3) 的 SDK 來刪除自訂模型部署。

```
def delete_custom_model_deployment(bedrock_client):
    """Delete a custom model deployment
 
    Args:
        bedrock_client: A boto3 Bedrock client for making API calls
 
    Returns:
        dict: The response from the delete operation
 
    Raises:
        Exception: If there is an error deleting the deployment
    """
 
    try:
        response = bedrock_client.delete_custom_model_deployment(
            customModelDeploymentIdentifier="Deployment identifier"
        )
 
        print(f"Deployment deletion initiated")
        return response
 
    except Exception as e:
        print(f"Error deleting deployment: {str(e)}")
        raise
```