在 model_config_file 中分配版本标签失败

Jea*_*lie 5 tensorflow tensorflow-serving

我有一个模型的版本 1 和 2,我正在尝试按照https://www.tensorflow.org/serving/serving_config#assigning_string_labels_to_model_versions_to_simplify_canary_and_rollback 上的说明为它们分配标签

我分别在/path/to/model/1和 中导出了两个版本,并/path/to/model/2使用以下命令启动服务器:

tensorflow_model_server --rest_api_port=8501 --model_config_file=models.config

以下models.config文件有效,并导致仅提供版本1(如果specific省略消息,则版本2按预期提供,因为它对应于最高数字):

model_config_list {
    config {
        name: 'm1'
        base_path: '/path/to/model/'
        model_platform: 'tensorflow'
        model_version_policy {
        specific {
            versions: 1
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经验证我可以使用服务器向模型发送请求并按预期执行推理。但是,如果我尝试version_labels使用此配置文件添加:

model_config_list {
    config {
        name: 'm1'
        base_path: '/path/to/model/'
        model_platform: 'tensorflow'
        model_version_policy {
        specific {
            versions: 1
        }
        version_labels {
            key: 'current'
            value: 1
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后启动服务器失败并出现以下错误:

Failed to start server. Error: Failed precondition: Request to assign label to version 1 of model m1, which is not currently available for inference.

我还注意到将value字段更改为不存在的版本文件夹会产生类似的结果:

Failed to start server. Error: Failed precondition: Request to assign label to version 1234 of model m1, which is not currently available for inference.

我正在使用:

TensorFlow ModelServer: 1.12.0-rc0+dev.sha.87470f0
TensorFlow Library: 1.12.0
Run Code Online (Sandbox Code Playgroud)

我找不到关于主题的任何 SO 问题,version_labels并且可用的 tensorflow 文档似乎不完整和过时(例如,它没有提到需要传入model_platform: 'tensorflow'配置文件)。

任何帮助将非常感激!

小智 0

参考https://www.tensorflow.org/tfx/serving/serving_config

请注意,标签只能分配给已加载且可用于服务的模型版本。一旦模型版本可用,就可以动态重新加载模型配置,为其分配标签(可以使用 HandleReloadConfigRequest RPC 端点来实现)。

也许您应该首先删除标签相关部分,然后启动张量流服务,最后将标签相关部分动态添加到配置文件中。