Skip to content

Instantly share code, notes, and snippets.

@bhoomit
Forked from johndpope/parseyapi.sh
Last active January 12, 2017 10:29
Show Gist options
  • Select an option

  • Save bhoomit/8f4a8c45be85eff8098fd7c150a852ee to your computer and use it in GitHub Desktop.

Select an option

Save bhoomit/8f4a8c45be85eff8098fd7c150a852ee 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 ../../
# zlib related patch
cd serving/tensorflow
curl -L https://gist.githubusercontent.com/bhoomit/6181e3f8cfa991741ee7eb90a8e1ea64/raw/29e9b049934171cb95eab21b89a54f3cd6d70e03/zlib_perm_link_tensorflow.patch > zlib_perm_link_tensorflow.patch
patch tensorflow/workspace.bzl < zlib_perm_link_tensorflow.patch
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