Skip to content

Instantly share code, notes, and snippets.

@johndpope
Last active March 10, 2017 16:34
Show Gist options
  • Save johndpope/fc1c2327a4ae255d9c44dda9b67b5288 to your computer and use it in GitHub Desktop.
Save johndpope/fc1c2327a4ae255d9c44dda9b67b5288 to your computer and use it in GitHub Desktop.
# Use with this Dockerfile https://github.com/johndpope/DockerParseyMcParsefaceAPI
# https://github.com/dsindex/syntaxnet/blob/master/README_api.md
cd /
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
pip install grpcio # does this fix things?
# 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
echo "\n\n\n\n" | ./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
#disable cuda on osx
bazel clean --expunge && export TF_NEED_CUDA=0
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 --local_resources 2048,.5,1.0
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment