下载tensorflow serving
$ git clone --recurse-submodules https://github.com/tensorflow/serving
$ cd serving
--recurse-submodules选项会拉取tensorflow serving依赖的Tensorflow,gRPC或者其他类库。
如果要指定版本,可以使用-b选项。
配置配置
配置tensorflow
$ cd tensorflow
$ ./configure
$ cd ..
构建tensorflow serving
bazel构建tensorflow serving
$ bazel build -c opt tensorflow_serving/...
或者可以使用优化参数构建
$ bazel build -c opt --config=mkl --copt=-msse4.1 --copt=-msse4.2 --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-O3 tensorflow_serving/...
构建完成之后,二进制文件会置于bazel-bin目录
$ bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server
验证构建结果
$ bazel test -c opt tensorflow_serving/...