Skip to content

Commit b8f791a

Browse files
committed
update serving to 2.5.1 and tensorflow to 2.5.0
update main.cc with upstream changes add support for libomp runtime add mkl and mkl_dnn patches and an additional tensorflow (xla) patch update curl patch to remove dep on project bazel config setting tensorflow repo now uses patches generated from git update docker base images to latest update tensorflow bazelrc build config
1 parent 4a14142 commit b8f791a

File tree

13 files changed

+234
-87
lines changed

13 files changed

+234
-87
lines changed

Diff for: .bazelrc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# upstream tensorflow/serving version
2-
build --embed_label=2.5.0
2+
build --embed_label=2.5.1
33

44
common --experimental_repo_remote_exec
55

@@ -30,7 +30,7 @@ import %workspace%/third_party/tensorflow/.bazelrc
3030

3131
# linux_amd64 base config group. use this config when cross-building
3232
# for custom amd64 targets (i.e. ones not defined here)
33-
build:linux_amd64 --platforms=@com_github_emacski_bazeltools//platform:linux_amd64
33+
build:linux_amd64 --platforms=@com_github_emacski_bazeltools//toolchain:linux_amd64
3434

3535
build:linux_amd64_avx_sse4.2 --config=linux_amd64
3636
build:linux_amd64_avx_sse4.2 --copt=-mavx
@@ -51,8 +51,8 @@ build:common_arm --copt=-fomit-frame-pointer
5151
# linux_arm64 base config group. use this config when cross-building
5252
# for custom 64 bit arm targets (i.e. ones not defined here)
5353
build:linux_arm64 --config=common_arm
54+
build:linux_arm64 --platforms=@com_github_emacski_bazeltools//toolchain:linux_arm64
5455
build:linux_arm64 --cpu=aarch64
55-
build:linux_arm64 --platforms=@com_github_emacski_bazeltools//platform:linux_arm64
5656
build:linux_arm64 --copt=-march=armv8-a
5757

5858
build:linux_arm64_armv8-a --config=linux_arm64
@@ -67,8 +67,8 @@ build:linux_arm64_armv8.2-a --define=tag_suffix=linux_arm64_armv8.2-a
6767
# linux_arm base config group. use this config when cross-building for
6868
# custom 32 bit arm targets (i.e. ones not defined here)
6969
build:linux_arm --config=common_arm
70-
build:linux_arm --cpu=arm
71-
build:linux_arm --platforms=@com_github_emacski_bazeltools//platform:linux_arm
70+
build:linux_arm --platforms=@com_github_emacski_bazeltools//toolchain:linux_arm
71+
build:linux_arm --cpu=armhf
7272
build:linux_arm --copt=-march=armv7-a
7373

7474
build:linux_arm_armv7-a_neon_vfpv4 --config=linux_arm

Diff for: BUILD.local_crosslib

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
filegroup(
4+
name = "libomp",
5+
srcs = ["libomp.so"],
6+
)

Diff for: README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ On many consumer / developer 64-bit and 32-bit arm platforms you can simply:
3737
```sh
3838
docker pull emacski/tensorflow-serving:latest
3939
# or
40-
docker pull emacski/tensorflow-serving:2.4.1
40+
docker pull emacski/tensorflow-serving:2.5.1
4141
```
4242

4343
Refer to [TensorFlow Serving with Docker](https://www.tensorflow.org/tfx/serving/docker)
@@ -58,7 +58,7 @@ for configuration and setting up a model for serving.
5858
Example
5959
```bash
6060
# on beaglebone black
61-
docker pull emacski/tensorflow-serving:2.4.1-linux_arm_armv7-a_neon_vfpv3
61+
docker pull emacski/tensorflow-serving:2.5.1-linux_arm_armv7-a_neon_vfpv3
6262
```
6363

6464
### Aliases
@@ -77,7 +77,7 @@ docker pull emacski/tensorflow-serving:2.4.1-linux_arm_armv7-a_neon_vfpv3
7777
Examples
7878
```bash
7979
# on Raspberry PI 3 B+
80-
docker pull emacski/tensorflow-serving:2.4.1-linux_arm64
80+
docker pull emacski/tensorflow-serving:2.5.1-linux_arm64
8181
# or
8282
docker pull emacski/tensorflow-serving:latest-linux_arm64
8383
```
@@ -113,9 +113,9 @@ docker pull emacski/tensorflow-serving:latest
113113
Example
114114
```sh
115115
# on Raspberry PI 3 B+
116-
docker pull emacski/tensorflow-serving:2.4.1
117-
# the actual image used is emacski/tensorflow-serving:2.4.1-linux_arm64
118-
# itself actually being emacski/tensorflow-serving:2.4.1-linux_arm64_armv8-a
116+
docker pull emacski/tensorflow-serving:2.5.1
117+
# the actual image used is emacski/tensorflow-serving:2.5.1-linux_arm64
118+
# itself actually being emacski/tensorflow-serving:2.5.1-linux_arm64_armv8-a
119119
```
120120

121121
### Debug Images
@@ -130,9 +130,9 @@ suffix (if one is required) in the image tag.
130130

131131
```sh
132132
# multi-arch
133-
docker pull emacski/tensorflow-serving:2.4.1-debug
133+
docker pull emacski/tensorflow-serving:2.5.1-debug
134134
# specific image
135-
docker pull emacski/tensorflow-serving:2.4.1-debug-linux_arm64_armv8-a
135+
docker pull emacski/tensorflow-serving:2.5.1-debug-linux_arm64_armv8-a
136136
# specific alias
137137
docker pull emacski/tensorflow-serving:latest-debug-linux_arm64
138138
```

Diff for: WORKSPACE

+19-18
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file"
1818

1919
http_archive(
2020
name = "com_github_emacski_bazeltools",
21-
sha256 = "36c3fb806547b202c98c137a41d2bb2aebf3a52dfc8dedc7d972c1731368e7c7",
22-
strip_prefix = "bazel-tools-7d90c92c3b361b0345451425d85d58a25de80ad9",
23-
urls = ["https://github.com/emacski/bazel-tools/archive/7d90c92c3b361b0345451425d85d58a25de80ad9.tar.gz"],
21+
sha256 = "dba9e8f0613401ed3c052d6fe79b3517197a7747046659845309fb17e9b3038d",
22+
strip_prefix = "bazel-tools-17a0d8b9ae66bc542853a72365ef1aeb85086827",
23+
urls = ["https://github.com/emacski/bazel-tools/archive/17a0d8b9ae66bc542853a72365ef1aeb85086827.tar.gz"],
2424
)
2525

2626
load(
@@ -71,17 +71,18 @@ http_archive(
7171
# arm (32-bit) datatype sizes
7272
"//third_party/tensorflow:curl.patch",
7373
"//third_party/tensorflow:hwloc.patch",
74-
# might be using host's cpu
74+
# set platform cpu constraint on aarch64 config_setting
7575
"//third_party/tensorflow:mkl.patch",
76-
# remove explicit dep on libgomp
76+
# remove explicit linker dep on libgomp
7777
"//third_party/tensorflow:mkl_dnn.patch",
7878
# allow android cpu helper to be used for linux_arm and linux_arm64
7979
"//third_party/tensorflow:tensorflow.patch",
8080
],
81-
sha256 = "68437339e0d5854d28157ba77a4ae30954f35d08899675e3bb6da9824fbb904a",
82-
strip_prefix = "tensorflow-0d1805aede03d25aa9d49adcef6903535fa5ad14",
81+
patch_args = ["-p1"],
82+
sha256 = "cb99f136dc5c89143669888a44bfdd134c086e1e2d9e36278c1eb0f03fe62d76",
83+
strip_prefix = "tensorflow-a4dfb8d1a71385bd6d122e4f27f86dcebb96712d",
8384
urls = [
84-
"https://github.com/tensorflow/tensorflow/archive/0d1805aede03d25aa9d49adcef6903535fa5ad14.tar.gz",
85+
"https://github.com/tensorflow/tensorflow/archive/a4dfb8d1a71385bd6d122e4f27f86dcebb96712d.tar.gz",
8586
],
8687
)
8788

@@ -113,13 +114,13 @@ http_archive(
113114
],
114115
)
115116

116-
# tensorflow serving 2.5.0
117+
# tensorflow serving 2.5.1
117118
http_archive(
118119
name = "tf_serving",
119-
sha256 = "eec408b6950c4d4d06d148ceb1567eaac0c28b9c38fbc2328fe96d07fec3e3d8",
120-
strip_prefix = "serving-bba3972185e47376a63d801ffcd2831684db114a",
120+
sha256 = "e94726632a0637a460b07e5e1c6c5a30c9f776dda22b5e9132b9ef526fbefa7e",
121+
strip_prefix = "serving-da76fc74b48f6afe190125f9ed572e690cef8570",
121122
urls = [
122-
"https://github.com/tensorflow/serving/archive/bba3972185e47376a63d801ffcd2831684db114a.tar.gz",
123+
"https://github.com/tensorflow/serving/archive/da76fc74b48f6afe190125f9ed572e690cef8570.tar.gz",
123124
],
124125
)
125126

@@ -243,15 +244,15 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
243244

244245
container_pull(
245246
name = "discolix_cc_linux_amd64",
246-
digest = "sha256:f888804401ae34244ae3dfe2286a004fea446848fcc9dbd9c19632910e1385f9",
247+
digest = "sha256:67268fbe9ca7e6ee25774dd3c5359a81eec285362ef0932f1eeed0e0bf32e0fd",
247248
registry = "index.docker.io",
248249
repository = "discolix/cc",
249250
tag = "latest-linux_amd64",
250251
)
251252

252253
container_pull(
253254
name = "discolix_cc_linux_amd64_debug",
254-
digest = "sha256:0fe8c9f1e0131dbcbc139263e92e4772c46e7161cd2392cd95bb7fd85e3ead97",
255+
digest = "sha256:b02ee67449f57d7b5eeefa611986151bbcf8bb0ff72b05f7b426848455e27ba6",
255256
registry = "index.docker.io",
256257
repository = "discolix/cc",
257258
tag = "debug-linux_amd64",
@@ -261,15 +262,15 @@ container_pull(
261262

262263
container_pull(
263264
name = "discolix_cc_linux_arm64",
264-
digest = "sha256:7eabd63fa0da92ea3cb04ed0fda7fdca8ea07fec8797fd692ae6f8d1419ca835",
265+
digest = "sha256:dec982052e6f6c1d28f1c1304d2a93b79a2169d8a3273e6029f1033c95be6f31",
265266
registry = "index.docker.io",
266267
repository = "discolix/cc",
267268
tag = "latest-linux_arm64",
268269
)
269270

270271
container_pull(
271272
name = "discolix_cc_linux_arm64_debug",
272-
digest = "sha256:2b0332cad7d88fd5d2a2fb1069914557673aef9a86caaa04930760a287a2ca81",
273+
digest = "sha256:c0a4668fc09e174d321f6d0d81e00cf1ee0515d7c220efdcf3b030a92ec98e1b",
273274
registry = "index.docker.io",
274275
repository = "discolix/cc",
275276
tag = "debug-linux_arm64",
@@ -279,15 +280,15 @@ container_pull(
279280

280281
container_pull(
281282
name = "discolix_cc_linux_arm",
282-
digest = "sha256:dbee6bebc8a85afbe0d3ce923e0296bf0fa5edd45a43bcc487a36d6868acf131",
283+
digest = "sha256:9834a18225f8d9f9651a2144867be78da77c517e1334f2c3c00619d3c62299cc",
283284
registry = "index.docker.io",
284285
repository = "discolix/cc",
285286
tag = "latest-linux_arm",
286287
)
287288

288289
container_pull(
289290
name = "discolix_cc_linux_arm_debug",
290-
digest = "sha256:f0dd6de42d29eb6f0436dc8345cb753099fc425387c9e361c954eb9365a4c89a",
291+
digest = "sha256:f1698d4d4d68b4c0c0a7d88a8c2b3abf55c4512ddc7212804d5c5760edb7918f",
291292
registry = "index.docker.io",
292293
repository = "discolix/cc",
293294
tag = "debug-linux_arm",

Diff for: tensorflow_model_server/BUILD

+20-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ load("@debian_buster_armhf//debs:deb_packages.bzl", "debian_buster_armhf")
2727
load("@debian_buster_arm64//debs:deb_packages.bzl", "debian_buster_arm64")
2828
load("@debian_buster_amd64//debs:deb_packages.bzl", "debian_buster_amd64")
2929

30+
package(default_visibility = ["//visibility:public"])
31+
3032
cc_library(
3133
name = "main_lib",
3234
srcs = [
@@ -35,6 +37,7 @@ cc_library(
3537
linkstamp = "stamp.cc",
3638
deps = [
3739
"@org_tensorflow//tensorflow/c:c_api",
40+
"@org_tensorflow//tensorflow/compiler/jit:xla_cpu_jit",
3841
"@org_tensorflow//tensorflow/core:lib",
3942
"@org_tensorflow//tensorflow/core/platform/cloud:gcs_file_system",
4043
"@org_tensorflow//tensorflow/core/platform/hadoop:hadoop_file_system",
@@ -90,6 +93,18 @@ container_layer(
9093
}),
9194
)
9295

96+
container_layer(
97+
name = "libomp_runtime",
98+
directory = select({
99+
":linux_arm64": "/usr/lib/aarch64-linux-gnu",
100+
":linux_amd64": "/usr/lib/x86_64-linux-gnu",
101+
}),
102+
files = select({
103+
":linux_arm64": ["@local_crosslib_arm64//:libomp"],
104+
":linux_amd64": ["@local_crosslib_amd64//:libomp"],
105+
})
106+
)
107+
93108
[container_image(
94109
name = "custom_image" + suffix,
95110
architecture = select({
@@ -112,7 +127,11 @@ container_layer(
112127
":tensorflow_model_server",
113128
":tf_serving_entrypoint.sh",
114129
],
115-
layers = ["dash"],
130+
layers = ["dash"] + select({
131+
":linux_arm64": ["libomp_runtime"],
132+
":linux_amd64": ["libomp_runtime"],
133+
"//conditions:default": [],
134+
}),
116135
ports = [
117136
"8500",
118137
"8501",

Diff for: tensorflow_model_server/main.cc

+47-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ limitations under the License.
4949
#include <vector>
5050

5151
#include "tensorflow/c/c_api.h"
52+
#include "tensorflow/compiler/jit/flags.h"
5253
#include "tensorflow/core/lib/core/status.h"
5354
#include "tensorflow/core/platform/init_main.h"
5455
#include "tensorflow/core/util/command_line_flags.h"
@@ -60,9 +61,11 @@ extern const char cBUILD_SCM_REV_STAMP[];
6061
int main(int argc, char** argv) {
6162
tensorflow::serving::main::Server::Options options;
6263
bool display_version = false;
64+
bool xla_cpu_compilation_enabled = false;
6365
std::vector<tensorflow::Flag> flag_list = {
6466
tensorflow::Flag("port", &options.grpc_port,
65-
"Port to listen on for gRPC API"),
67+
"TCP port to listen on for gRPC/HTTP API. Disabled if "
68+
"port set to zero."),
6669
tensorflow::Flag("grpc_socket_path", &options.grpc_socket_path,
6770
"If non-empty, listen to a UNIX socket for gRPC API "
6871
"on the given path. Can be either relative or absolute "
@@ -76,6 +79,9 @@ int main(int argc, char** argv) {
7679
"set, will be auto set based on number of CPUs."),
7780
tensorflow::Flag("rest_api_timeout_in_ms", &options.http_timeout_in_ms,
7881
"Timeout for HTTP/REST API calls."),
82+
tensorflow::Flag("rest_api_enable_cors_support",
83+
&options.enable_cors_support,
84+
"Enable CORS headers in response"),
7985
tensorflow::Flag("enable_batching", &options.enable_batching,
8086
"enable batching"),
8187
tensorflow::Flag(
@@ -108,6 +114,18 @@ int main(int argc, char** argv) {
108114
tensorflow::Flag("model_base_path", &options.model_base_path,
109115
"path to export (ignored if --model_config_file flag "
110116
"is set, otherwise required)"),
117+
tensorflow::Flag("num_load_threads", &options.num_load_threads,
118+
"The number of threads in the thread-pool used to load "
119+
"servables. If set as 0, we don't use a thread-pool, "
120+
"and servable loads are performed serially in the "
121+
"manager's main work loop, may casue the Serving "
122+
"request to be delayed. Default: 0"),
123+
tensorflow::Flag("num_unload_threads", &options.num_unload_threads,
124+
"The number of threads in the thread-pool used to "
125+
"unload servables. If set as 0, we don't use a "
126+
"thread-pool, and servable loads are performed serially "
127+
"in the manager's main work loop, may casue the Serving "
128+
"request to be delayed. Default: 0"),
111129
tensorflow::Flag("max_num_load_retries", &options.max_num_load_retries,
112130
"maximum number of times it retries loading a model "
113131
"after the first failure, before giving up. "
@@ -178,6 +196,8 @@ int main(int argc, char** argv) {
178196
"A comma separated list of arguments to be passed to "
179197
"the grpc server. (e.g. "
180198
"grpc.max_connection_age_ms=2000)"),
199+
tensorflow::Flag("grpc_max_threads", &options.grpc_max_threads,
200+
"Max grpc server threads to handle grpc messages."),
181201
tensorflow::Flag("enable_model_warmup", &options.enable_model_warmup,
182202
"Enables model warmup, which triggers lazy "
183203
"initializations (such as TF optimizations) at load "
@@ -199,11 +219,32 @@ int main(int argc, char** argv) {
199219
"model from `saved_model.pb` file. "
200220
"If no TensorFlow Lite model found, fallback to "
201221
"TensorFlow model."),
222+
tensorflow::Flag(
223+
"num_tflite_pools", &options.num_tflite_pools,
224+
"EXPERIMENTAL; CAN BE REMOVED ANYTIME! Number of TFLite interpreters "
225+
"in an interpreter pool of TfLiteSession. Typically there is one "
226+
"TfLiteSession for each TF Lite model that is loaded. If not "
227+
"set, will be auto set based on number of CPUs."),
228+
tensorflow::Flag(
229+
"num_tflite_interpreters_per_pool",
230+
&options.num_tflite_interpreters_per_pool,
231+
"EXPERIMENTAL; CAN BE REMOVED ANYTIME! Number of TFLite interpreters "
232+
"in an interpreter pool of TfLiteSession. Typically there is one "
233+
"TfLiteSession for each TF Lite model that is loaded. If not "
234+
"set, will be 1."),
202235
tensorflow::Flag(
203236
"enable_signature_method_name_check",
204237
&options.enable_signature_method_name_check,
205238
"Enable method_name check for SignatureDef. Disable this if serving "
206-
"native TF2 regression/classification models.")};
239+
"native TF2 regression/classification models."),
240+
tensorflow::Flag(
241+
"xla_cpu_compilation_enabled", &xla_cpu_compilation_enabled,
242+
"EXPERIMENTAL; CAN BE REMOVED ANYTIME! "
243+
"Enable XLA:CPU JIT (default is disabled). With XLA:CPU JIT "
244+
"disabled, models utilizing this feature will return bad Status "
245+
"on first compilation request."),
246+
tensorflow::Flag("enable_profiler", &options.enable_profiler,
247+
"Enable profiler service.")};
207248

208249
const auto& usage = tensorflow::Flags::Usage(argv[0], flag_list);
209250
if (!tensorflow::Flags::Parse(&argc, argv, flag_list)) {
@@ -223,6 +264,10 @@ int main(int argc, char** argv) {
223264
std::cout << "unknown argument: " << argv[1] << "\n" << usage;
224265
}
225266

267+
if (!xla_cpu_compilation_enabled) {
268+
tensorflow::DisableXlaCompilation();
269+
}
270+
226271
tensorflow::serving::main::Server server;
227272
const auto& status = server.BuildAndStart(options);
228273
if (!status.ok()) {

0 commit comments

Comments
 (0)