fastprep.mk 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # -*- Mode: Makefile -*-
  2. #
  3. # Copyright 2016 Google Inc. All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # This makefile builds "fastprep", a faster version of prep.py that can be used
  17. # to build training data for Swivel. Building "fastprep" is a bit more
  18. # involved: you'll need to pull and build the Tensorflow source, and then build
  19. # and install compatible protobuf software. We've tested this with Tensorflow
  20. # version 0.7.
  21. #
  22. # = Step 1. Pull and Build Tensorflow. =
  23. #
  24. # These instructions are somewhat abridged; for pre-requisites and the most
  25. # up-to-date instructions, refer to:
  26. #
  27. # <https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html#installing-from-sources>
  28. #
  29. # To build the Tensorflow components required for "fastpret", you'll need to
  30. # install Bazel, Numpy, Swig, and Python development headers as described in at
  31. # the above URL. Run the "configure" script as appropriate for your
  32. # environment and then build the "build_pip_package" target:
  33. #
  34. # bazel build -c opt [--config=cuda] //tensorflow/tools/pip_package:build_pip_package
  35. #
  36. # This will generate the Tensorflow headers and libraries necessary for
  37. # "fastprep".
  38. #
  39. #
  40. # = Step 2. Build and Install Compatible Protobuf Libraries =
  41. #
  42. # "fastprep" also needs compatible protocol buffer libraries, which you can
  43. # build from the protobuf implementation included with the Tensorflow
  44. # distribution:
  45. #
  46. # cd ${TENSORFLOW_SRCDIR}/google/protobuf
  47. # ./autogen.sh
  48. # ./configure --prefix=${HOME} # ...or whatever
  49. # make
  50. # make install # ...or maybe "sudo make install"
  51. #
  52. # This will install the headers and libraries appropriately.
  53. #
  54. #
  55. # = Step 3. Build "fastprep". =
  56. #
  57. # Finally modify this file (if necessary) to update PB_DIR and TF_DIR to refer
  58. # to appropriate locations, and:
  59. #
  60. # make -f fastprep.mk
  61. #
  62. # If all goes well, you should have a program that is "flag compatible" with
  63. # "prep.py" and runs significantly faster. Use it to generate the co-occurrence
  64. # matrices and other files necessary to train a Swivel matrix.
  65. # The root directory where the Google Protobuf software is installed.
  66. # Alternative locations might be "/usr" or "/usr/local".
  67. PB_DIR=$(HOME)
  68. # Assuming you've got the Tensorflow source unpacked and built in ${HOME}/src:
  69. TF_DIR=$(HOME)/src/tensorflow
  70. PB_INCLUDE=$(PB_DIR)/include
  71. TF_INCLUDE=$(TF_DIR)/bazel-genfiles
  72. CXXFLAGS=-std=c++11 -m64 -mavx -g -Ofast -Wall -I$(TF_INCLUDE) -I$(PB_INCLUDE)
  73. PB_LIBDIR=$(PB_DIR)/lib
  74. TF_LIBDIR=$(TF_DIR)/bazel-bin/tensorflow/core
  75. LDFLAGS=-L$(TF_LIBDIR) -L$(PB_LIBDIR)
  76. LDLIBS=-lprotos_all_cc -lprotobuf -lpthread -lm
  77. fastprep: fastprep.cc