Skip to content

Commit

Permalink
Fix fastprep.mk for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarkovtsev committed Mar 2, 2017
1 parent 7a77d60 commit cb85c55
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions swivel/fastprep.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
# limitations under the License.



# This makefile builds "fastprep", a faster version of prep.py that can be used
# to build training data for Swivel.
#
# = Step 1. Install Tensorflow. =
# = Step 1. Install protobuf v3 =
#
# pip3 install tensorflow[-gpu]
# Ubuntu 16.10+: sudo apt install libprotobuf-dev
# Ubuntu 16.04: https://launchpad.net/~maarten-fonville/+archive/ubuntu/ppa + replace xenial with yakkety in /etc/apt/sources.list.d/maarten-fonville-ubuntu-ppa-xenial.list
# macOS: brew install protobuf
#
# = Step 2. Build "fastprep". =
#
Expand All @@ -32,20 +33,28 @@
# "prep.py" and runs significantly faster. Use it to generate the co-occurrence
# matrices and other files necessary to train a Swivel matrix.

PYVER_CMD='import sys; print("%d.%d" % sys.version_info[:2])'
PYVER=$(shell python3 -c $(PYVER_CMD) || python -c $(PYVER_CMD))
$(info Python version: $(PYVER))
TF_DIR=$(shell python$(PYVER) -c 'import os, tensorflow; print(os.path.dirname(tensorflow.__file__))')
$(info Tensorflow installation: $(TF_DIR))

TF_INCLUDE=$(TF_DIR)/include
CXXFLAGS=-std=c++11 -march=native -g -O2 -Wall -I$(TF_INCLUDE)
CXXFLAGS=-std=c++11 -march=native -g -O2 -flto -Wall -I.
LDLIBS=-lprotobuf -pthread -lm

FETCHER=curl -L -o
TF_URL=https://github.com/tensorflow/tensorflow/raw/master
PROTOC=protoc


%.proto: tensorflow/core/example
$(FETCHER) $@ $(TF_URL)/$@

%.pb.cc: %.proto
$(PROTOC) --cpp_out=. $<

TF_LIBDIR=$(TF_DIR)/python
LDFLAGS=-L$(TF_LIBDIR) -Wl,-rpath,$(TF_LIBDIR)
LDLIBS=-l:_pywrap_tensorflow.so -lprotobuf -lpython$(PYVER)m -pthread -lm
fastprep: fastprep.cc tensorflow/core/example/feature.pb.cc tensorflow/core/example/example.pb.cc

fastprep: fastprep.cc
tensorflow/core/example:
@mkdir -p tensorflow/core/example

clean:
@rm -f fastprep
@rm -f fastprep

mrproper: clean
@rm -rf tensorflow

0 comments on commit cb85c55

Please sign in to comment.