GCP AI 平台(统一)Python export_model FailedPrecondition: 400 不支持以`` 格式导出工件
GCP AI Platform (unified) Python export_model FailedPrecondition: 400 Exporting artifact in format `` is not supported
我正在使用 Google AiPlatform(统一)Python 客户端将经过训练的模型导出到 Google 云存储桶。我正在关注以下示例代码:export_model_sample.
该应用程序目前具有“所有者”凭据,因为我想确保这不是权限问题。但是,当我尝试执行示例代码时出现以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 923, in call
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 826, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.FAILED_PRECONDITION
details = "Exporting artifact for model projects/101010101010/locations/us-central1/models/123123123123123
in format is not supported." debug_error_string = "{"created":"@1611864688.554145696","description":"Error received from peer ipv4:172.217.12.202:443","file":"src/core/lib/surface/call.cc","file_line":1067,"grpc_message":"Exporting artifact for model `projects/110101010101/locations/us-central1/models/123123123123123` in format
is not supported.","grpc_status":9}"
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/app/main.py", line 667, in
response = aiplatform_model_client.export_model(name=name, output_config=output_config) File
"/usr/local/lib/python3.8/site-packages/google/cloud/aiplatform_v1beta1/services/model_service/client.py",
line 937, in export_model
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) File
"/usr/local/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py",
line 145, in call
return wrapped_func(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py",
line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc) File "", line 3, in raise_from
google.api_core.exceptions.FailedPrecondition: 400 Exporting artifact
for model
projects/111101010101/locations/us-central1/models/123123123123123123
in format `` is not supported.
(我省略了项目id和模型id。使用10101和123123)
我已经验证了我的输入,但似乎一切正常:
gcs_destination_output_uri_prefix = "gs://my-bucket-vcm/model-123123123123123/tflite/2021-01-28T16:00:00.000Z/"
gcs_destination = {"output_uri_prefix": gcs_destination_output_uri_prefix}
output_config = {"artifact_destination": gcs_destination,}
name = "projects/10101010101/locations/us-central1/models/123123123123123"
response = aiplatform_model_client.export_model(name=name, output_config=output_config)
print("Long running operation:", response.operation.name)
export_model_response = response.result(timeout=300)
print("export_model_response:", export_model_response)
我也在用最新版的google-cloud-aiplatform==0.4.0
我尝试导出的模型类型为:MOBILE_TF_LOW_LATENCY_1
我只想将模型导出到云存储桶。不将其部署为服务。
AI Platform 统一 REST 中的 export_model_sample is missing a request field. You should include "export_format_id": string
in the output_config
. You can further explore the required output_config
fields required by export endpoint API 参考。
export_format_id
的可接受值如下:
tflite
用于 Android 移动设备。
edgetpu-tflite
用于边缘 TPU 设备。
tf-saved-model
SavedModel 格式的张量流模型。
tf-js
一个TensorFlow.js模型,可以在浏览器和
Node.js 使用 JavaScript.
core-ml
用于 iOS 移动设备。
custom-trained
通过自定义代码上传或训练的模型。
代码应如下所示。在这种情况下,我使用 tflite
作为 export_format_id
。
from google.cloud import aiplatform
def export_model_sample(
project: str = "your-project-id",
model_id: str = "your-model-id",
gcs_destination_output_uri_prefix: str = "your-bucket-destination",
location: str = "us-central1",
api_endpoint: str = "us-central1-aiplatform.googleapis.com",
timeout: int = 300,
):
# The AI Platform services require regional API endpoints.
client_options = {"api_endpoint": api_endpoint}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
output_config = {
"export_format_id": "tflite",
"artifact_destination": {"output_uri_prefix": gcs_destination_output_uri_prefix}
}
name = client.model_path(project=project, location=location, model=model_id)
response = client.export_model(name=name, output_config=output_config)
print("Long running operation:", response.operation.name)
export_model_response = response.result(timeout=timeout)
print("export_model_response:", export_model_response)
export_model_sample()
我在操作完成后得到了一个这样命名的模型:
gs://your-bucket-destination/your-model-id/tflite/2021-01-29T04:15:51.672336Z/model.tflite
我正在使用 Google AiPlatform(统一)Python 客户端将经过训练的模型导出到 Google 云存储桶。我正在关注以下示例代码:export_model_sample.
该应用程序目前具有“所有者”凭据,因为我想确保这不是权限问题。但是,当我尝试执行示例代码时出现以下错误:
Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable return callable_(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 923, in call return _end_unary_response_blocking(state, call, False, None) File "/usr/local/lib/python3.8/site-packages/grpc/_channel.py", line 826, in _end_unary_response_blocking raise _InactiveRpcError(state) grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.FAILED_PRECONDITION details = "Exporting artifact for model
projects/101010101010/locations/us-central1/models/123123123123123
in formatis not supported." debug_error_string = "{"created":"@1611864688.554145696","description":"Error received from peer ipv4:172.217.12.202:443","file":"src/core/lib/surface/call.cc","file_line":1067,"grpc_message":"Exporting artifact for model `projects/110101010101/locations/us-central1/models/123123123123123` in format
is not supported.","grpc_status":9}"The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/app/main.py", line 667, in response = aiplatform_model_client.export_model(name=name, output_config=output_config) File "/usr/local/lib/python3.8/site-packages/google/cloud/aiplatform_v1beta1/services/model_service/client.py", line 937, in export_model response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) File "/usr/local/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 145, in call return wrapped_func(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File "", line 3, in raise_from google.api_core.exceptions.FailedPrecondition: 400 Exporting artifact for model
projects/111101010101/locations/us-central1/models/123123123123123123
in format `` is not supported.
(我省略了项目id和模型id。使用10101和123123)
我已经验证了我的输入,但似乎一切正常:
gcs_destination_output_uri_prefix = "gs://my-bucket-vcm/model-123123123123123/tflite/2021-01-28T16:00:00.000Z/"
gcs_destination = {"output_uri_prefix": gcs_destination_output_uri_prefix}
output_config = {"artifact_destination": gcs_destination,}
name = "projects/10101010101/locations/us-central1/models/123123123123123"
response = aiplatform_model_client.export_model(name=name, output_config=output_config)
print("Long running operation:", response.operation.name)
export_model_response = response.result(timeout=300)
print("export_model_response:", export_model_response)
我也在用最新版的google-cloud-aiplatform==0.4.0 我尝试导出的模型类型为:MOBILE_TF_LOW_LATENCY_1
我只想将模型导出到云存储桶。不将其部署为服务。
AI Platform 统一 REST 中的 export_model_sample is missing a request field. You should include "export_format_id": string
in the output_config
. You can further explore the required output_config
fields required by export endpoint API 参考。
export_format_id
的可接受值如下:
tflite
用于 Android 移动设备。edgetpu-tflite
用于边缘 TPU 设备。tf-saved-model
SavedModel 格式的张量流模型。tf-js
一个TensorFlow.js模型,可以在浏览器和 Node.js 使用 JavaScript.core-ml
用于 iOS 移动设备。custom-trained
通过自定义代码上传或训练的模型。
代码应如下所示。在这种情况下,我使用 tflite
作为 export_format_id
。
from google.cloud import aiplatform
def export_model_sample(
project: str = "your-project-id",
model_id: str = "your-model-id",
gcs_destination_output_uri_prefix: str = "your-bucket-destination",
location: str = "us-central1",
api_endpoint: str = "us-central1-aiplatform.googleapis.com",
timeout: int = 300,
):
# The AI Platform services require regional API endpoints.
client_options = {"api_endpoint": api_endpoint}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
output_config = {
"export_format_id": "tflite",
"artifact_destination": {"output_uri_prefix": gcs_destination_output_uri_prefix}
}
name = client.model_path(project=project, location=location, model=model_id)
response = client.export_model(name=name, output_config=output_config)
print("Long running operation:", response.operation.name)
export_model_response = response.result(timeout=timeout)
print("export_model_response:", export_model_response)
export_model_sample()
我在操作完成后得到了一个这样命名的模型:
gs://your-bucket-destination/your-model-id/tflite/2021-01-29T04:15:51.672336Z/model.tflite