使用带有TensorFlow服务的语法

时间:2017-03-06 10:23:52

标签: tensorflow grpc tensorflow-serving syntaxnet

我尝试使用带有TensorFlow服务的语法。

我找到了此链接here。我尝试运行脚本来启动服务器:

# you can create a shell script with content below!

git clone https://github.com/dsindex/syntaxnet.git work
cd work
git clone --recurse-submodules https://github.com/tensorflow/serving
# checkout proper version of serving
cd serving
git checkout 89e9dfbea055027bc31878ee8da66b54a701a746
git submodule update --init --recursive
# checkout proper version of tf_models
cd tf_models
git checkout a4b7bb9a5dd2c021edcd3d68d326255c734d0ef0

# you need to install gRPC properly
# https://tensorflow.github.io/serving/setup
# if you have a trouble, see https://github.com/dsindex/tensorflow#tensorflow-serving

# apply patch by dmansfield to serving/tf_models/syntaxnet 
cd serving/tf_models
patch -p1 < ../../api/pr250-patch-a4b7bb9a.diff.txt
cd ../../

# configure serving/tensorflow
cd serving/tensorflow
./configure
cd ../../

# modify serving/tensorflow_serving/workspace.bzl for referencing syntaxnet
cp api/modified_workspace.bzl serving/tensorflow_serving/workspace.bzl
cat api/modified_workspace.bzl
#  ... 
#  native.local_repository(
#    name = "syntaxnet",
#    path = workspace_dir + "/tf_models/syntaxnet",
#  )
#  ...

# append build instructions to serving/tensorflow_serving/example/BUILD
cat api/append_BUILD >> serving/tensorflow_serving/example/BUILD

# copy parsey_api.cc, parsey_api.proto to example directory to build
cp api/parsey_api* serving/tensorflow_serving/example/

# build parsey_api 
cd serving
bazel --output_user_root=bazel_root build --nocheck_visibility -c opt -s //tensorflow_serving/example:parsey_api --genrule_strategy=standalone --spawn_strategy=standalone --verbose_failures

# make softlink for referencing 'syntaxnet/models/parsey_mcparseface/context.pbtxt'
ln -s ./tf_models/syntaxnet/syntaxnet syntaxnet

# run parsey_api with exported model
./bazel-bin/tensorflow_serving/example/parsey_api --port=9000 ../api/parsey_model

但对于下面的行(构建parsey_api时):

bazel --output_user_root=bazel_root build --nocheck_visibility -c opt -s //tensorflow_serving/example:parsey_api --genrule_strategy=standalone --spawn_strategy=standalone --verbose_failures

我收到了一个错误:

Extracting Bazel installation...
........
ERROR: Failed to load Skylark extension '//tensorflow/tensorflow:workspace.bzl'.
It usually happens when the repository is not defined prior to being used.
Maybe repository '' was defined later in your WORKSPACE file?
ERROR: cycles detected during target parsing.
INFO: Elapsed time: 2.298s
./batch.sh: line 52: ./bazel-bin/tensorflow_serving/example/parsey_api: No such file or directory

file workspace.bzl位于目录$BUILD_DIRECTORY/tensorflow/tensorflow

我正在使用:

  • Ubuntu 14.04
  • Bazel 0.4.4
  • 安装了python gPRC

谢谢你的任何建议都是受欢迎的。

0 个答案:

没有答案