Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code to Build Tensorflow Serving from source within a Docker container
mkdir -p /work/
# Clone the source from Github
cd /work/ && git clone — recurse-submodules https://github.com/tensorflow/serving
# Pin the version of Tensorflow Serving and its submodule
TENSOR_SERVING_COMMIT_HASH=85db9d3
TENSORFLOW_COMMIT_HASH=dbe5e17
cd /work/serving && git checkout $TENSOR_SERVING_COMMIT_HASH
cd /work/serving/tensorflow && git checkout $TENSORFLOW_COMMIT_HASH
cd /work/serving/tensorflow && ./configure
# Tensorflow Serving uses Bazel as the build tool. The Docker image already have Bazel installed in it.
# Run the following command to build the source with Bazel
cd /work/serving && bazel build -c opt //tensorflow_serving/model_servers:tensorflow_model_server --jobs 10 --curses no --discard_analysis_cache
# The following bazel option flags was added:
# -c (compilation_mode): the compilation mode flag affects the the C++ generation. ‘opt’ compilation mode is selected to enable optimization and disable the assert calls.
# — discard_analysis_cache: will discard the analysis cache immediately after the analysis phase completes. This reduces memory usage by ~10%, but makes further incremental builds slower. 
# — jobs: The default number of jobs spawned by bazel is 200. Depending on the system configuration of your host, you might like to update this parameter. We tune ours to 10.
@alanmarazzi
Copy link

alanmarazzi commented Oct 2, 2017

In line 5 — recurse-submodules is wrong, it should be --recursive 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment