【问题标题】:Tensorflow Serving error serviing tensorflow version 1.5 modelTensorflow Serving 错误服务 tensorflow 1.5 版模型
【发布时间】:2022-04-04 06:00:57
【问题描述】:

在 docker 容器中运行 Tensorflow Serving 时收到以下错误消息

2019-12-12 03:25:13.947401: I tensorflow_serving/model_servers/server.cc:85] Building single TensorFlow model file config:  model_name: mymodel model_base_path: /models/mymodel 
2019-12-12 03:25:13.947870: I tensorflow_serving/model_servers/server_core.cc:462] Adding/updating models.
2019-12-12 03:25:13.947891: I tensorflow_serving/model_servers/server_core.cc:573]  (Re-)adding model: mymodel
2019-12-12 03:25:14.058166: I tensorflow_serving/core/basic_manager.cc:739] Successfully reserved resources to load servable {name: mymodel version: 1}
2019-12-12 03:25:14.058430: I tensorflow_serving/core/loader_harness.cc:66] Approving load for servable version {name: mymodel version: 1}
2019-12-12 03:25:14.059106: I tensorflow_serving/core/loader_harness.cc:74] Loading servable version {name: mymodel version: 1}
2019-12-12 03:25:14.064459: E tensorflow_serving/util/retrier.cc:37] Loading servable: {name: mymodel  version: 1} failed: Not found: Specified file path does not appear to contain a SavedModel bundle (should have a file called `saved_model.pb`)
Specified file path: /models/mymodel/1

该模型是使用 tensorflow v1.5 构建的,没有 *.pb 文件。是否可以运行此版本的 tensorflow 模型?任何想法表示赞赏。提前致谢。

【问题讨论】:

    标签: tensorflow tensorflow-serving


    【解决方案1】:

    是的,您可以在 tfserving 上部署在 Tensorflow v1.5 上训练的模型。

    TfServing 需要 SavedModel 格式。

    您的训练脚本可能存在一些配置问题。 (但由于您没有提供代码,因此很难确定,请始终尝试将代码包含在您关于 SO 的问题中,以便其他人更好地理解)


    回答您的问题,

    要获得SavedModel 格式,请通过official script 训练您的模型。

    训练后,你会在你指定的模型目录中得到如下目录结构。

    <model_dir>
    |
    |----- variables
    |         |------- variables.data-00000-of-00001
    |         |------- variables.index
    |
    |----- saved_model.pb
    

    然后你可以直接指定&lt;model_dir&gt;路径到tfserving,它就会使用这个模型。

    【讨论】:

      【解决方案2】:

      您不能将 h5 用于 tf 服务,但您可以使用以下代码轻松地将 h5 模型转换为 SavedModel:

      import tensorflow as tf
      
      model = tf.keras.models.load_model('./model/best-model.h5')
      export_path = './model/1'
      
      tf.saved_model.save(model, export_path)
      

      以后再用。

      【讨论】:

        猜你喜欢
        • 2017-09-24
        • 2018-05-16
        • 1970-01-01
        • 2018-09-29
        • 2019-04-21
        • 2018-08-03
        • 2019-11-27
        • 2018-02-01
        • 2017-08-09
        相关资源
        最近更新 更多