持久性資源會持續提供,直到刪除為止。刪除後,如果發生缺貨情形,系統不保證您能再次建立相同資源類型的永久資源。本頁面說明如何使用 Google Cloud 控制台、Google Cloud CLI、Vertex AI SDK for Python 和 REST API 刪除永久性資源。
必要的角色
如要取得刪除永久性資源所需的權限,請要求管理員為您授予專案的 Vertex AI 管理員 (roles/aiplatform.admin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這個預先定義的角色包含 aiplatform.persistentResources.delete
權限,這是刪除永久性資源所需的權限。
刪除永久性資源
如要瞭解如何在不再需要時刪除永久性資源,請選取下列任一分頁。請注意,如果您刪除永久性資源時,有在該資源上執行的自訂工作,這些自訂工作會在永久性資源刪除前自動取消。
控制台
如要在 Google Cloud 控制台刪除永久資源,請按照下列步驟操作:
在 Google Cloud 控制台,前往「Persistent resources」(永久性資源) 頁面。
按一下要刪除的永久性資源名稱。
按一下
「刪除」。按一下「確認」。
gcloud
使用下列任何指令資料之前,請先替換以下項目:
- PROJECT_ID:要刪除的永久性資源專案 ID。
- LOCATION:您要刪除的永久性資源區域。
- PERSISTENT_RESOURCE_ID:您要刪除的永久資源 ID。
執行下列指令:
Linux、macOS 或 Cloud Shell
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID \ --project=PROJECT_ID \ --region=LOCATION
Windows (PowerShell)
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID ` --project=PROJECT_ID ` --region=LOCATION
Windows (cmd.exe)
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID ^ --project=PROJECT_ID ^ --region=LOCATION
您應該會收到類似以下的回應:
Using endpoint [https://us-central1-aiplatform.googleapis.com/] Request to delete the PersistentResource [projects/sample-project/locations/us-central1/persistentResources/test-persistent-resource] has been sent. You may view the status of your persistent resource with the command $ gcloud ai persistent-resources describe projects/sample-project/locations/us-central1/persistentResources/test-persistent-resource
Python
在試用這個範例之前,請先按照 Vertex AI 快速入門:使用用戶端程式庫中的操作說明設定 Python。詳情請參閱 Vertex AI Python API 參考說明文件。
如要向 Vertex AI 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。
from google.cloud.aiplatform.preview import persistent_resource resource_to_delete = persistent_resource.PersistentResource( PERSISTENT_RESOURCE_ID ) # Delete the persistent resource. resource_to_delete.delete(sync=True)
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:要刪除的永久性資源專案 ID。
- LOCATION:您要刪除的永久性資源區域。
- PERSISTENT_RESOURCE_ID:您要刪除的永久資源 ID。
HTTP 方法和網址:
DELETE https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/persistentResources/PERSISTENT_RESOURCE_ID
如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{ "name": "projects/123456789012/locations/us-central1/operations/1234567890123456789", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata", "genericMetadata": { "createTime": "2023-07-28T17:22:08.316883Z", "updateTime": "2023-07-28T17:22:08.316883Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.protobuf.Empty" } }