Tensorflow serving提供了部署tensorflow生成的模型给线上服务的方法,包括模型的export,load等等。
安装参考这个
https://github.com/tensorflow/serving/blob/master/tensorflow_serving/g3doc/setup.md
?
?
但是由于被qiang的问题 (googlesource无法访问)
https://github.com/tensorflow/serving/issues/6
需要修改一下 WORKSPACE文件
new_http_archive(
name = "gmock_archive",
#url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
url = "https://github.com/peter-wangxu/gmock/archive/1.7.0.zip",
#sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
sha256 = "9b0018413f4222b8ee5454a431918c324d010062eecb078677b6897d0c76bc42",
build_file = "tensorflow/google/protobuf/gmock.BUILD",
)
?
?
git_repository(
name = "boringssl_git",
#commit = "436432d849b83ab90f18773e4ae1c7a8f148f48d",
commit = "db0729054d5964feab9e60089ba2d06a181e78b1",
init_submodules = True,
#remote = "https://github.com/mdsteele/boringssl-bazel.git",
remote = "https://github.com/doubler/boringssl-bazel.git",
)
?
?
?
?
注意需要先进入tensorflow路径
./configure一下
?
?
?
?
bazel build tensorflow_serving/…
?
?
最后验证一下
./bazel-bin/tensorflow_serving/example/mnist_inference --port=9000 ~/tmp/
I tensorflow_serving/session_bundle/session_bundle.cc:109] Attempting to load a SessionBundle from: /home/gezi/tmp/
E tensorflow_serving/example/mnist_inference.cc:190] Fail to load tensorflow export: /home/gezi/tmp/export.meta
gezi:~/other/serving$ bazel test tensorflow_serving/...
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
INFO: Found 89 targets and 36 test targets...
INFO: Elapsed time: 31.664s, Critical Path: 28.86s
//tensorflow_serving/batching:batch_scheduler_test PASSED in 0.3s
//tensorflow_serving/batching:retrier_test PASSED in 0.2s
//tensorflow_serving/batching:streaming_batch_scheduler_test PASSED in 4.1s
//tensorflow_serving/batching/test_util:puppet_batch_scheduler_test PASSED in 0.2s
//tensorflow_serving/core:availability_helpers_test PASSED in 0.3s
//tensorflow_serving/core:dynamic_manager_benchmark PASSED in 28.5s
//tensorflow_serving/core:dynamic_manager_test PASSED in 0.3s
//tensorflow_serving/core:eager_load_policy_test PASSED in 0.2s
?
?
?
?
?
?