This is what I use to deploy an Auto-ML model:
MachineSpec machineSpec = MachineSpec.newBuilder().setMachineType("n1-standard-2").build();
DedicatedResources dedicatedResources =
DedicatedResources.newBuilder().setMinReplicaCount(1).setMachineSpec(machineSpec).build();
String model = ModelName.of(project, location, modelId).toString();
DeployedModel deployedModel =
DeployedModel.newBuilder()
.setModel(model)
.setDisplayName(deployedModelDisplayName)
.setDedicatedResources(dedicatedResources)
.build();
Map<String, Integer> trafficSplit = new HashMap<>();
trafficSplit.put("0", 100);
EndpointName endpoint = EndpointName.of(project, location, endpointId);
OperationFuture<DeployModelResponse, DeployModelOperationMetadata> response =
client.deployModelAsync(endpoint, deployedModel, trafficSplit);
response.getInitialFuture().get().getName());
The error appears when I hit this line response.getInitialFuture().get().getName());
Here is the error:
INVALID_ARGUMENT: 'dedicated_resources' is not supported for Model projects/***/locations/us-central1/models/***
I can deploy the model using cloud console but not programmatically using java 8. It is a new model and the endpoint is also new without any assigned model to it.
I am sorry everyone, I was implementing the wrong section of the documentation. I had to follow AutoML image, not Custom-trained one.