我已经设法使用UndeployModelRequest从端点卸载了一个模型。
model_name = f'projects/{project}/locations/{location}/models/{model_id}'
model_request = aiplatform_v1.types.GetModelRequest(name=model_name)
model_info = client_model.get_model(request=model_request)
deployed_models_info = model_info.deployed_models
deployed_model_id=model_info.deployed_models[0].deployed_model_id
undeploy_request = aiplatform_v1.types.UndeployModelRequest
(endpoint=end_point, deployed_model_id=deployed_model_id)
client.undeploy_model(request=undeploy_request)但这一切都取决于对model_id的了解。我希望能够在不知道模型的id的情况下从端点卸载模型(每个端点只有一个模型)。这是可能的,还是我可以从端点获得模型id?
发布于 2022-09-26 11:58:23
通过调用方法undeploy_all() (见清洁部分).Here,您可以从端点卸载所有模型,而不需要传递模型id。此方法将对您更有用,因为您将在端点中只有一个模型。
下面是从特定端点卸载所有模型的示例:
from google.cloud import aiplatform
def undeploy_model_from_endpoint(names):
endpoints = aiplatform.Endpoint.list()
for i in endpoints:
if str(i.display_name)==names:
i.undeploy_all()
undeploy_model_from_endpoint("Endpoint_name")如果希望从所有端点卸载所有模型,只需删除if条件即可。
endpoints = aiplatform.Endpoint.list()
for i in endpoints:
i.undeploy_all()https://stackoverflow.com/questions/73811793
复制相似问题