【问题标题】:Bad model detected when deploying model on google ml engine在 google ml 引擎上部署模型时检测到错误模型
【发布时间】:2019-11-02 23:07:14
【问题描述】:

我使用具有以下配置的 google ml 引擎训练了我的模型。

JOB_NAME=object_detection"_$(date +%m_%d_%Y_%H_%M_%S)"
echo $JOB_NAME
gcloud ml-engine jobs submit training $JOB_NAME \
        --job-dir=gs://$1/train \
        --scale-tier BASIC_GPU \
        --runtime-version 1.12 \
        --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
        --module-name object_detection.model_main \
        --region europe-west1 \
        -- \
        --model_dir=gs://$1/train \
        --pipeline_config_path=gs://$1/data/fast_rcnn_resnet101_coco.config

训练后,我从 GCP 下载了最新的检查点并使用以下命令导出模型:

python export_inference_graph.py --input_type encoded_image_string_tensor --pipeline_config_path training/fast_rcnn_resnet101_coco.config --trained_checkpoint_prefix training/model.ckpt-11127 --output_directory exported_graphs

我的模型配置如下所示:

The given SavedModel SignatureDef contains the following input(s):
  inputs['inputs'] tensor_info:
      dtype: DT_UINT8
      shape: (-1, -1, -1, 3)
      name: image_tensor:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['detection_boxes'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300, 4)
      name: detection_boxes:0
  outputs['detection_classes'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300)
      name: detection_classes:0
  outputs['detection_features'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, -1, -1, -1, -1)
      name: detection_features:0
  outputs['detection_multiclass_scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300, 2)
      name: detection_multiclass_scores:0
  outputs['detection_scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300)
      name: detection_scores:0
  outputs['num_detections'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1)
      name: num_detections:0
  outputs['raw_detection_boxes'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300, 4)
      name: raw_detection_boxes:0
  outputs['raw_detection_scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 300, 2)
      name: raw_detection_scores:0
Method name is: tensorflow/serving/predict

在此之后,我在 ml-engine 上部署了这个模型,配置如下:

Python version 2.7
Framework TensorFlow
Framework version 1.12.3
Runtime version 1.12
Machine type Single core CPU

我收到以下错误:

错误

创建版本失败。检测到错误模型错误:“无法加载模型:加载可服务:{名称:默认版本:1}失败:未找到:在本地主机上运行的二进制文件中未注册操作类型“FusedBatchNormV3”。确保操作和内核已注册在此过程中运行的二进制文件。请注意,如果您正在加载使用来自 tf.contrib 的操作的已保存图,则应在导入图之前访问(例如)tf.contrib.resampler,因为当模块首次使用时,contrib 操作会延迟注册已访问。\n\n (错误代码: 0)"

【问题讨论】:

    标签: google-cloud-ml


    【解决方案1】:

    这很可能是某个地方的 Tf 版本不兼容,例如在模型和运行时之间。您是否使用实际运行的 Tf 版本创建模型?

    许多话题似乎证实了我的回答:

    Not found: Op type not registered 'CountExtremelyRandomStats'

    Bad model deploying to GCP Cloudml

    【讨论】:

    • 我在 GCP 上创建了运行时版本为 1.12 的模型,并使用相同的运行时版本进行部署。但是我在本地导出了模型,所以 tf 和 python 版本在我的本地环境中是不同的。
    【解决方案2】:

    我能够弄清楚:当我导出模型时,我使用的是不同的 Tensorflow 版本。为了保持连贯性并避免此类错误,请确保训练、导出和部署期间的 Tensorflow 版本都相同。

    【讨论】:

    • 原来如此
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-13
    • 2019-06-21
    • 2022-10-13
    • 1970-01-01
    • 2018-10-03
    • 2019-11-25
    • 2018-01-30
    相关资源
    最近更新 更多