首页 > 解决方案 > GCloud MLEngine:创建版本失败。检测到错误模型错误:加载模型失败:需要类似字节的对象,而不是“str”(错误代码:0)

问题描述

我正在尝试在 google cloud ml 模型下为成功训练的 tensorflow 估计器模型创建版本。我相信我提供了正确的 Uri(在谷歌存储中),其中包括 saved_model.pb。

框架:Tensorflow,框架版本:1.13.1,运行时版本:1.13,Python:3.5

这是错误的回溯:

Traceback (most recent call last):
  File "/google/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 985, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 795, in Run
    resources = command_instance.Run(args)
  File "/google/google-cloud-sdk/lib/surface/ml_engine/versions/create.py", line 119, in Run
    python_version=args.python_version)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/command_lib/ml_engine/versions_util.py", line 114, in Create
    message='Creating version (this might take a few minutes)...')
  File "/google/google-cloud-sdk/lib/googlecloudsdk/command_lib/ml_engine/versions_util.py", line 75, in WaitForOpMaybe
    return operations_client.WaitForOperation(op, message=message).response
  File "/google/google-cloud-sdk/lib/googlecloudsdk/api_lib/ml_engine/operations.py", line 114, in WaitForOperation
    sleep_ms=5000)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 264, in WaitFor
    sleep_ms, _StatusUpdate)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 326, in PollUntilDone
    sleep_ms=sleep_ms)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 229, in RetryOnResult
    if not should_retry(result, state):
  File "/google/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 320, in _IsNotDone
    return not poller.IsDone(operation)
  File "/google/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 122, in IsDone
    raise OperationError(operation.error.message)
OperationError: Bad model detected with error:  "Failed to load model: a bytes-like object is required, not 'str' (Error code: 0)"
ERROR: (gcloud.ml-engine.versions.create) Bad model detected with error:  "Failed to load model: a bytes-like object is required, not 'str' (Error code: 0)"

你知道可能是什么问题吗?

编辑

我正在使用: tf.estimator.LatestExporter('exporter', model.serving_input_fn) 作为估算器出口商。

serving_input_fn:

def serving_input_fn():
    inputs = {'string1': tf.placeholder(tf.int16, [None, MAX_SEQUENCE_LENGTH]),
              'string2': tf.placeholder(tf.int16, [None, MAX_SEQUENCE_LENGTH])}

    return tf.estimator.export.ServingInputReceiver(inputs, inputs)

PS:我的模型接受两个输入并返回一个二进制输出。

标签: tensorflowgoogle-cloud-platformgoogle-cloud-mltensorflow-estimator

解决方案


推荐阅读