How to undeploy a model, or specifically how to get deployed model's id from shell on Vertex AI?

Viewed 952

In order to undeploy a model from an endpoint via shell i must specify the deployed-model-id as described in gcloud ai endpoints undeploy-model

How do i get this deployed model id?

2 Answers

gcloud ai endpoints describe $ENDPOINT_ID output

Apparently, to get the deployed model id you need the output of gcloud ai endpoints describe ENDPOINT_ID underlined with pink is the deployed model id ('id: ') underlined with yellow is the actual model id,

To get all depoly-model-ids of a model you can do:

gcloud ai endpoints describe $ENDPOINT_ID --region=$GCP_REGION | grep -A 1 "id:" | grep -B 1 $MODEL_ID | grep -v $MODEL_ID

And use it to undeploy a model using:

gcloud ai endpoints undeploy-model ENDPOINT_ID --deployed-model-id=DEPLOYED_MODEL_ID

Although the question was related to using it in Shell, I came across this question because I was struggling with finding this field deployed_model_id programmatically in Python, this thread has actually helped me a lot. If it may help future people looking for the same thing as me, one can find this attribute in the Endpoint class:

aiplatform.Endpoint.gca_resource.deployed_models[0].id

If it helps, one small snippet that takes just the first endpoint from a list of endpoints in Vertex AI and prints out its deployed_model_id:

from google.cloud import aiplatform
from google.cloud import aiplatform_v1
# Make sure you have your GCP credentials authenticated on your local
endpoints = aiplatform.Endpoint.list()
print(endpoints[0].gca_resource.deployed_models[0].id
Related