我试图使用Python在Google平台上部署一个与顶点AI一起训练的文本分类模型。
from google.cloud import aiplatform
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "<key location>"
def create_endpoint(
project_id: str,
display_name: str,
location: str,
sync: bool = True,
):
endpoint = aiplatform.Endpoint.create(
display_name=display_name, project=project_id, location=location,
)
print(endpoint.display_name)
print(endpoint.resource_name)
return endpoint
def deploy_model(project_id, location, model_id):
model_location = "projects/{}/locations/{}/models/{}".format(project_id, location, model_id)
print("Initializing Vertex AI")
aiplatform.init(project=project_id, location=location)
print("Getting model from {}".format(model_location))
model = aiplatform.Model(model_location)
print("Creating endpoint.")
endpoint = create_endpoint(project_id, "{}_endpoint".format(model_id), location)
print("Deploying endpoint")
endpoint.deploy(
model,
machine_type="n1-standard-4",
min_replica_count=1,
max_replica_count=5,
accelerator_type='NVIDIA_TESLA_K80',
accelerator_count=1
)
return endpoint
endpoint = deploy_model(
"<project name>",
"us-central1",
"<model id>",
)不幸的是,当我运行这段代码时,我会在触发endpoint.deploy之后收到这个错误:google.api_core.exceptions.InvalidArgument: 400 'dedicated_resources' is not supported for Model...,后面跟着模型位置。
注意我用<***>交换了值以隐藏本地工作区变量的位置。
发布于 2021-10-15 04:13:37
您会遇到错误,因为无法将自定义机器分配给文本分类模型。只有自定义模型和AutoML表格模型可以按照文档使用自定义机器。对于AutoML模型,除了表格模型之外,顶点AI会自动配置机器类型。
如果要使用经过自定义培训的模型或AutoML表格模型来提供在线预测,则必须在将模型资源部署为DeployedModel到终结点时指定计算机类型。对于其他automatically.模型的类型,顶点AI配置机器类型 AutoML
解决这一问题的方法是删除endpoint.deploy()上与机器相关的参数,您应该能够部署模型。
print("Deploying endpoint")
endpoint.deploy(model)https://stackoverflow.com/questions/69577270
复制相似问题