dave-edison
dave-edison

Reputation: 3726

`Model.deploy()` failing for AutoML with `400 'automatic_resources' is not supported for Model`

Trying to use the python SDK to deploy an AutoML model, but am recieving the error

google.api_core.exceptions.InvalidArgument: 400 'automatic_resources' is not supported for Model

Here's what I'm running:

from google.cloud import aiplatform

aiplatform.init(project="MY_PROJECT")

# model is an AutoML tabular model
model = aiplatform.Model("MY_MODEL_ID")

# this fails
model.deploy()

Upvotes: 0

Views: 412

Answers (1)

Ricco D
Ricco D

Reputation: 7277

You encounter the automatic_resources because deploying models for AutoML Tables requires the user to define the machine type at model deployment. See configure compute resources for prediction docs for more information.

If you want to use a custom-trained model or an AutoML tabular model to serve online predictions, you must specify a machine type when you deploy the Model resource as a DeployedModel to an Endpoint.

You should add defining of resources to your code for you to continue the deployment. Adding machine_type parameter should suffice. See supported machine types docs for complete list.

See code below:

from google.cloud import aiplatform

project = "your-project-id"
location = "us-central1"
model_id = "99999999"

aiplatform.init(project=project, location=location)
model_name = (f"projects/{project}/locations/{location}/models/{model_id}")

model = aiplatform.Model(model_name=model_name)

model.deploy(machine_type="n1-standard-4")

model.wait()
print(model.display_name)

Output:

enter image description here

Upvotes: 1

Related Questions