Get persistent resource information

This page shows you how to get a list of persistent resources and how to get information about a specific persistent resource by Google Cloud console, Google Cloud CLI, Vertex AI SDK for Python, and the REST API.

Required roles

To get the permissions that you need to get persistent resource information, ask your administrator to grant you the Vertex AI Viewer (roles/aiplatform.viewer) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to get persistent resource information. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to get persistent resource information:

  • aiplatform.persistentResources.get
  • aiplatform.persistentResources.list

You might also be able to get these permissions with custom roles or other predefined roles.

Get a list of persistent resources

Select one of the following tabs for instructions on how to get a list of existing persistent resources.

Console

To view a list of persistent resources in the Google Cloud console, go to the Persistent resources page.

Go to Persistent resources

gcloud

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

  • PROJECT_ID: The Project ID of the Google Cloud project that you want to get a list persistent resources for.
  • LOCATION: The region where you want to create the persistent resource. For a list of supported regions, see Feature availability.

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud ai persistent-resources list \
    --project=PROJECT_ID \
    --region=LOCATION

Windows (PowerShell)

gcloud ai persistent-resources list `
    --project=PROJECT_ID `
    --region=LOCATION

Windows (cmd.exe)

gcloud ai persistent-resources list ^
    --project=PROJECT_ID ^
    --region=LOCATION

You should receive a response similar to the following:

Response

Using endpoint [https://us-central1-aiplatform.googleapis.com/]
---
createTime: '2023-09-12T20:45:33.220989Z'
displayName: test
name: projects/123456789012/locations/us-central1/persistentResources/test-persistent-resource
resourcePools:
- autoscalingSpec:
    maxReplicaCount: '4'
    minReplicaCount: '1'
  diskSpec:
    bootDiskSizeGb: 100
    bootDiskType: pd-standard
  id: n1-highmem-2-nvidia-tesla-t4-1
  machineSpec:
    acceleratorCount: 1
    acceleratorType: NVIDIA_TESLA_T4
    machineType: n1-highmem-2
  replicaCount: '1'
startTime: '2023-09-12T20:50:36.992739253Z'
state: RUNNING
updateTime: '2023-09-12T20:50:42.813723Z'
---
createTime: '2023-09-12T20:37:21.691977Z'
displayName: my-persistent-resource
name: projects/123456789012/locations/us-central1/persistentResources/my-persistent-resource
resourcePools:
- autoscalingSpec:
    maxReplicaCount: '12'
    minReplicaCount: '4'
  diskSpec:
    bootDiskSizeGb: 200
    bootDiskType: pd-standard
  id: n1-highmem-2-nvidia-tesla-t4-1
  machineSpec:
    acceleratorCount: 1
    acceleratorType: NVIDIA_TESLA_T4
    machineType: n1-highmem-2
  replicaCount: '4'
- diskSpec:
    bootDiskSizeGb: 100
    bootDiskType: pd-ssd
  id: n1-standard-4
  machineSpec:
    machineType: n1-standard-4
  replicaCount: '4'
startTime: '2023-09-12T20:42:46.495575169Z'
state: RUNNING
updateTime: '2023-09-12T20:42:51.519271Z'

Python

Before trying this sample, follow the Python setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Python API reference documentation.

To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# Optional arguments:
# filter (str): An expression for filtering the results of the request. For
#   field names both snake_case and camelCase are supported.
# order_by (str): A comma-separated list of fields to order by, sorted in
#   ascending order. Use "desc" after a field name for descending. Supported
#   fields: `display_name`, `create_time`, `update_time`

# List the persistent resource on the project.
resource_list = persistent_resource.PersistentResource.list()

for i in range(len(resource_list)):
    print(resource_list[i].name)
    print(resource_list[i].state)

REST

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

  • PROJECT_ID: The Project ID of the Google Cloud project that you want to get a list persistent resources for.
  • LOCATION: The region where you want to create the persistent resource. For a list of supported regions, see Feature availability.

HTTP method and URL:

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

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

Get information about a persistent resource

Select one of the following tabs for instructions on how to get information about a persistent resource, including its status, hardware configuration, and available replicas.

Console

To view information about 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

  2. Click the name of the persistent resource that you want to view.

gcloud

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

  • PROJECT_ID: The Project ID of the persistent resource that you want to get information about.
  • LOCATION: The region of the persistent resource that you want to get information about.
  • PERSISTENT_RESOURCE_ID: The ID of the persistent resource that you want to get information about.

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud ai persistent-resources describe PERSISTENT_RESOURCE_ID \
    --project=PROJECT_ID \
    --region=LOCATION

Windows (PowerShell)

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

Windows (cmd.exe)

gcloud ai persistent-resources describe PERSISTENT_RESOURCE_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION

You should receive a response similar to the following:

Response

Using endpoint [https://us-central1-aiplatform.googleapis.com/]
createTime: '2023-07-06T18:47:42.098296Z'
displayName: Test-Persistent-Resource
name: projects/123456789012/locations/us-central1/persistentResources/my-persistent-resource
resourcePools:
- diskSpec:
    bootDiskSizeGb: 100
    bootDiskType: pd-ssd
  machineSpec:
    machineType: n1-highmem-4
  replicaCount: '4'
- diskSpec:
    bootDiskSizeGb: 100
    bootDiskType: pd-ssd
  machineSpec:
    acceleratorCount: 1
    acceleratorType: NVIDIA_TESLA_P4
    machineType: n1-standard-4
  replicaCount: '4'
  usedReplicaCOunt: '2'
startTime: '2023-07-06T18:51:53.209127117Z'
state: RUNNING
updateTime: '2023-07-06T18:52:01.545109Z'

Python

Before trying this sample, follow the Python setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Python API reference documentation.

To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

resource_to_get = persistent_resource.PersistentResource(
    EXAMPLE_PERSISTENT_RESOURCE_ID
)

print(resource_to_get.display_name)
print(resource_to_get.state)
print(resource_to_get.start_time)

REST

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

  • PROJECT_ID: The Project ID of the persistent resource that you want to get information about.
  • LOCATION: The region of the persistent resource that you want to get information about.
  • PERSISTENT_RESOURCE_ID: The ID of the persistent resource that you want to get information about.

HTTP method and URL:

GET 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:

You should receive a JSON response similar to the following:

{
  "name": "projects/123456789012/locations/us-central1/persistentResources/test-persistent-resource",
  "displayName": "test",
  "resourcePools": [
    {
      "id": "n1-highmem-2-nvidia-tesla-t4-1",
      "machineSpec": {
        "machineType": "n1-highmem-2",
        "acceleratorType": "NVIDIA_TESLA_T4",
        "acceleratorCount": 1
      },
      "replicaCount": "1",
      "diskSpec": {
        "bootDiskType": "pd-standard",
        "bootDiskSizeGb": 100
      },
      "autoscalingSpec": {
        "minReplicaCount": "1",
        "maxReplicaCount": "4"
      }
    }
  ],
  "state": "RUNNING",
  "createTime": "2023-09-12T20:45:33.220989Z",
  "startTime": "2023-09-12T20:50:36.992739253Z",
  "updateTime": "2023-09-12T20:50:42.813723Z"
}

What's next