Persistent resources are available until they are deleted. Once deleted, there
is no guarantee that you can create the persistent resource of the same resource
type again if there's a stockout. This page shows you how to delete a
persistent resource by using the Google Cloud console, Google Cloud CLI,
Agent Platform SDK for Python, and the REST API.

## Required roles


To get the permission that
you need to delete a persistent resource,

ask your administrator to grant you the
[Agent Platform Administrator](https://docs.cloud.google.com/iam/docs/roles-permissions/aiplatform.md.txt#aiplatform.admin) (`roles/aiplatform.admin`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains the
`aiplatform.persistentResources.delete`
permission,
which is required to
delete a persistent resource.


You might also be able to get
this permission
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

## Delete a persistent resource

For instructions on how to delete a persistent resource when you no longer
needed it, select one of the following tabs. Note that if there are custom jobs
running on the persistent resource when you delete it, those custom jobs are
automatically cancelled before the persistent resource is deleted.

### Console

To delete a persistent resource in the Google Cloud console, do the following:

1. In the Google Cloud console, go to the **Persistent resources** page.

   [Go to Persistent resources](https://console.cloud.google.com/agent-platform/training/persistent-resources)
2. Click the name of the persistent resource that you want to delete.

3. Click **Delete**.

4. Click **Confirm**.


### gcloud


Before using any of the command data below,
make the following replacements:

- <var class="edit" scope="PROJECT_ID" translate="no">PROJECT_ID</var>: The Project ID of the persistent resource that you want to delete.
- <var class="edit" scope="LOCATION" translate="no">LOCATION</var>: The region of the persistent resource that you want to delete.
- <var class="edit" scope="PERSISTENT_RESOURCE_ID" translate="no">PERSISTENT_RESOURCE_ID</var>: The ID of the persistent resource that you want to delete.


Execute the

following

command:

#### Linux, macOS, or Cloud Shell

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID \
    --project=PROJECT_ID \
    --region=LOCATION
```

#### Windows (PowerShell)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID `
    --project=PROJECT_ID `
    --region=LOCATION
```

#### Windows (cmd.exe)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud ai persistent-resources delete PERSISTENT_RESOURCE_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION
```

You should receive a response similar to the following:

```
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


Before trying this sample, follow the Python setup instructions in the
[Agent Platform quickstart using
client libraries](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/start/client-libraries).


To authenticate to Agent Platform, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
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


Before using any of the request data,
make the following replacements:

- <var class="edit" scope="PROJECT_ID" translate="no">PROJECT_ID</var>: The Project ID of the persistent resource that you want to delete.
- <var class="edit" scope="LOCATION" translate="no">LOCATION</var>: The region of the persistent resource that you want to delete.
- <var class="edit" scope="PERSISTENT_RESOURCE_ID" translate="no">PERSISTENT_RESOURCE_ID</var>: The ID of the persistent resource that you want to delete.


HTTP method and URL:

```
DELETE https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/persistentResources/PERSISTENT_RESOURCE_ID
```

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
curl -X DELETE \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/persistentResources/PERSISTENT_RESOURCE_ID"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method DELETE `
    -Headers $headers `
    -Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/persistentResources/PERSISTENT_RESOURCE_ID" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "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"
  }
}
```

<br />

## What's next

- [Learn about persistent resource](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/training/persistent-resource-overview.md.txt).
- [Run training jobs on a persistent resource](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/training/persistent-resource-train.md.txt).
- [Create and use a persistent resource](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/training/persistent-resource-create.md.txt).
- [Get information about a persistent resource](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/training/persistent-resource-get.md.txt).
- [Reboot a persistent resource](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/training/persistent-resource-reboot.md.txt).