Skip to content

Files

Latest commit

2f94ccb · Mar 31, 2018

History

History
94 lines (87 loc) · 3.49 KB

syntaxnet_setup_for_osx.md

File metadata and controls

94 lines (87 loc) · 3.49 KB

Syntaxnet setup for OSx

I’ve setup tensorflow-syntaxnet in a virtual env named ‘tf’ in OsX. Please find the below steps that helped me in getting the build successful in OsX:

  1. Setup virtual environment named ‘tf’.
virtualenv -p /usr/local/bin/python tf
source tf/bin/activate
  1. Install six - tensor flow dependency:
sudo easy_install --upgrade six
  1. Install tensor flow:
sudo pip install --upgrade tensorflow
  1. Test tensor flow installation with helloworld in python terminal:
python
import tensorflow as tf
hello = tf.constant('HelloWorld, Tensorflow!!')
sess = tf.session()
print(sess.run(hello))
  1. Install SyntaxNet Dependencies:
brew install swig
pip freeze | grep protobuf
sudo pip install -U protobuf==3.2.0
pip install asciitree
pip install numpy
pip install autograd==1.1.13
Install bazel 0.5.4
  - Download bazel-0.5.4-without-jdk-installer-darwin-x86_64.sh from  https://github.com/bazelbuild/bazel/releases 
  - chmod +x ~/Downloads/bazel-0.5.4-without-jdk-installer-darwin-x86_64.sh
  - sh ~/Downloads/bazel-0.5.4-without-jdk-installer-darwin-x86_64.sh
pip install mock
brew install graphviz
pip install pygraphviz
  1. Download syntaxnet:
cd <LOCATION_TO_WHERE_SYNTAXNET_REPO_WILL_BE_COPIED>
git clone --recursive https://github.com/tensorflow/models.git
  1. Configure:
cd <LOCATION_TO_WHERE_SYNTAXNET_REPO_IS_COPIED>/models/research/syntaxnet/tensorflow
./configure
  1. Build Syntaxnet:
cd <LOCATION_TO_WHERE_SYNTAXNET_REPO_IS_COPIED>
run “bazel test --linkopt=-headerpad_max_install_names dragnn/... syntaxnet/... util/utf8/…”

All the tests should pass with the above command and it will create bazel-bin directory in <LOCATION_TO_WHERE_SYNTAXNET_REPO_IS_COPIED>/models/research/syntaxnet/bazel-bin. This is the bin folder using which we'll package syntaxnet as module and install it. Before that, let's test the installation. 9. Test Syntaxnet:

cd <LOCATION_TO_WHERE_SYNTAXNET_REPO_IS_COPIED>/models/research/syntaxnet
echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh
  1. Output:

image

  1. Bundle syntaxnet package in .whl packaging format.
mkdir /tmp/syntaxnet_pkg
cd <LOCATION_TO_WHERE_SYNTAXNET_REPO_IS_COPIED>/models/research/syntaxnet
bazel-bin/dragnn/tools/build_pip_package --output-dir=/tmp/syntaxnet_pkg
**Output:** Wrote /tmp/syntaxnet_pkg/syntaxnet-0.2-cp27-cp27m-macosx_10_6_intel.whl
  1. Install syntaxnet module:
sudo pip install /tmp/syntaxnet_pkg/syntaxnet-0.2-cp27-cp27m-macosx_10_6_intel.whl

Output: Successfully installed syntaxnet-0.2

Verification

Open up python shell and check that the following imports work fine
python
from syntaxnet import sentence_pb2
from syntaxnet import graph_builder
from syntaxnet import structured_graph_builder
from syntaxnet.ops import load_parser_ops
from syntaxnet.ops import gen_parser_ops
from syntaxnet import task_spec_pb2

Appendix - Hammering Syntaxnet to behave

There were a bunch of errors I faced before I could reach this final point of successful installation with imports working in python shell. I've listed the issues that i faced here and how i went about fixing them here. Hope that saves some time for you :)