Tensorflow与contrib操作一起

时间:2018-11-13 15:50:02

标签: python tensorflow tensorflow-serving

如果有tf.contrib操作,如何使用tensorflow-serving服务模型。我通过Docker(最新)(tf 1.11版本)使用Tensorflow Serving,当我为模型提供服务时,会出现下一条消息:

“Failed to start server. Error: Unknown: 1 servable(s) did not become available: {{{name: slider_universal version: 1} due to error: Not found: Op type not registered ‘ImageProjectiveTransformV2’ in binary running on 254345a5d9f1. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.}, }”

我也使用bazel进行构建,但存在相同的错误

我使用tf.contrib.image.transform

如果我在导出模型期间删除了此操作,则可以通过tensorflow提供服务

1 个答案:

答案 0 :(得分:0)

我在使用同一个op时遇到了问题,看来唯一的方法就是构建它。

tensorflow_serving/model_servers/BUILD定义了哪些Tensorflow操作将包含在变量SUPPORTED_TENSORFLOW_OPS中,对此我有点困惑,因为它指定应包含contrib操作。但是,由于tensorflow contrib构建规则似乎不包含contrib.image下的ops,因此我通过将此变量更新为以下内容来显式添加了这些

SUPPORTED_TENSORFLOW_OPS = [
    "@org_tensorflow//tensorflow/contrib:contrib_kernels",
    "@org_tensorflow//tensorflow/contrib:contrib_ops_op_lib",
    "@org_tensorflow//tensorflow/contrib/image:image_ops_kernels",
    "@org_tensorflow//tensorflow/contrib/image:image_ops_op_lib",
]