持續性資源會保留到刪除為止。刪除後,如果缺貨,我們無法保證您能再次建立相同資源類型的永久資源。本頁說明如何使用 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
在試用這個範例之前,請先按照Python使用用戶端程式庫的 Vertex AI 快速入門中的操作說明進行設定。 詳情請參閱 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" } }