如何配置tensorflow服务来服务hdfs中的模型?

ep6jt1vc  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(626)

我正在尝试使用tensorflow服务项目从HDF中提供tensorflow模型。
我正在运行tensorflow服务docker容器标签1.10.1https://hub.docker.com/r/tensorflow/serving
我可以看到tensorflow/serving repo引用hadoophttps://github.com/tensorflow/serving/blob/628702e1de1fa3d679369e9546e7d74fa91154d3/tensorflow_serving/model_servers/build#l341

"@org_tensorflow//tensorflow/core/platform/hadoop:hadoop_file_system"

这是对
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/platform/hadoop/hadoop_file_system.cc
我设置了以下环境变量:
hadoop\u hdfs\u home指向我的hdfs home(/etc/hadoop在我的例子中)。
型号\基本\路径设置为“hdfs://tensorflow/models"
model\u name设置为要加载的模型的名称
我将hadoop安装到docker容器中,并可以使用docker exec进行验证。
当我运行docker容器时,我在日志中得到以下内容:

tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:369] FileSystemStoragePathSource encountered a file-system access error: Could not find base path hdfs://tensorflow/models/my_model for servable my_model

我发现了tensorflow使用hdfs进行训练的例子,但没有使用tensorflow服务来服务hdfs中的模型。
tensorflow服务可以服务于hdfs的模型吗?如果是,你怎么做?

8tntrjer

8tntrjer1#

BUILDmodel_servers ,在 cc_test 为了 get_model_status_impl_test ,添加此行 @org_tensorflow//tensorflow/core/platform/hadoop:hadoop_file_system ,如下图:

cc_test(
    name = "get_model_status_impl_test",
    size = "medium",
    srcs = ["get_model_status_impl_test.cc"],
    data = [
        "//tensorflow_serving/servables/tensorflow/testdata:saved_model_half_plus_two_2_versions",
    ],
    deps = [
        ":get_model_status_impl",
        ":model_platform_types",
        ":platform_config_util",
        ":server_core",
        "//tensorflow_serving/apis:model_proto",
        "//tensorflow_serving/core:availability_preserving_policy",
        "//tensorflow_serving/core/test_util:test_main",
        "//tensorflow_serving/servables/tensorflow:saved_model_bundle_source_adapter_proto",
        "//tensorflow_serving/servables/tensorflow:session_bundle_config_proto",
        "//tensorflow_serving/servables/tensorflow:session_bundle_source_adapter_proto",
        "//tensorflow_serving/test_util",
        "@org_tensorflow//tensorflow/cc/saved_model:loader",
        "@org_tensorflow//tensorflow/cc/saved_model:signature_constants",
        "@org_tensorflow//tensorflow/contrib/session_bundle",
        "@org_tensorflow//tensorflow/core:test",
        "@org_tensorflow//tensorflow/core/platform/hadoop:hadoop_file_system",
    ],
)

我想这会解决你的问题。
参考:无法从hdfs加载模型

相关问题