Skip to content

Commit ecb468f

Browse files
dmiltr3tensorflow-copybara
authored andcommitted
TF Serving Dockerfiles upgraded for a hermetic build. MKL stays non-hermetic at this time because of strict linker checks in llvm_openmp.
PiperOrigin-RevId: 895497907
1 parent 3ad3a3c commit ecb468f

18 files changed

Lines changed: 68 additions & 39 deletions

File tree

.bazelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ build:cuda --@local_config_cuda//:enable_cuda
1111
build:cuda_clang --config=cuda
1212
build:cuda_clang --copt=-Wno-gnu-offsetof-extensions
1313
build:cuda_clang --copt=-Wno-error=unused-command-line-argument
14+
build --linkopt=-Wno-unused-command-line-argument
15+
build --host_linkopt=-Wno-unused-command-line-argument
1416
build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument
1517
build:cuda_clang --repo_env TF_NEED_TENSORRT=0
1618
build:cuda_clang --action_env=TF_CUDA_CLANG="1"
@@ -23,9 +25,6 @@ build:cuda_clang --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5"
2325
build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10"
2426
build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang"
2527

26-
build:kokoro --repo_env=CC="/usr/bin/gcc-10"
27-
build:kokoro --action_env=CC="/usr/bin/gcc-10"
28-
2928
# Options used to build with TPU support.
3029
build:tpu --define=with_tpu_support=true --define=framework_shared_object=false
3130
build:tpu --copt=-DLIBTPU_ON_GCE
@@ -115,8 +114,12 @@ common --incompatible_enable_cc_toolchain_resolution
115114
common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1
116115
common --repo_env=HERMETIC_PYTHON_VERSION="3.10"
117116
build --features=-layering_check
117+
build --define=framework_shared_object=false
118+
build --dynamic_mode=off
119+
118120

119121
common:clang_local --noincompatible_enable_cc_toolchain_resolution
120122
common:clang_local --noincompatible_enable_android_toolchain_resolution
121123
common:clang_local --@rules_ml_toolchain//cc_toolchain/config:enable_hermetic_cc=False
122124
common:clang_local --repo_env USE_HERMETIC_CC_TOOLCHAIN=0
125+

WORKSPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ tensorflow_http_archive(
2727
sha256 = "86150d55ce57b2298d8ed42caa7b91c466ad33d9f7f347117c2257cc576d3413",
2828
git_commit = "72fbba3d20f4616d7312b5e2b7f79daf6e82f2fa",
2929
patch = "//third_party/tensorflow:tensorflow.patch",
30+
patch_cmds = [
31+
"sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl",
32+
"echo -e \"\\ndef cc_library_oss(deps=[], **kwargs):\\n if kwargs.get(\\\"name\\\") == \\\"lib_internal_impl\\\" or \\\"protobuf\\\" in kwargs.get(\\\"name\\\", \\\"\\\"):\\n _cc_library(deps = deps, **kwargs)\\n return\\n if type(deps) == \\\"list\\\":\\n if \\\"@com_google_protobuf//:protobuf\\\" not in deps:\\n deps = deps + [\\\"@com_google_protobuf//:protobuf\\\"]\\n else:\\n deps = deps + [\\\"@com_google_protobuf//:protobuf\\\"]\\n _cc_library(deps = deps, **kwargs)\\ncc_library = cc_library_oss\" >> tensorflow/core/platform/rules_cc.bzl",
33+
"sed -i 's#deps = \\[op_gen\\] + deps#deps = [op_gen] + deps + [clean_dep(\"//tensorflow/core/framework:kernel_shape_util\"), clean_dep(\"//tensorflow/core/framework:full_type_util\")]#' tensorflow/tensorflow.bzl",
34+
"sed -i '/name = \"kernel_shape_util\",/a \\ visibility = [\"//visibility:public\"],' tensorflow/core/framework/BUILD",
35+
],
3036
)
3137

3238
# Import all of TensorFlow Serving's external dependencies.

tensorflow_serving/example/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ cc_binary(
2929
"//tensorflow_serving/apis:prediction_service_cc_proto",
3030
"@com_github_grpc_grpc//:grpc++",
3131
"@com_google_protobuf//:protobuf_lite",
32+
"@local_xla//xla/tsl/util:command_line_flags",
3233
"@org_tensorflow//tensorflow/core:framework",
3334
"@org_tensorflow//tensorflow/core:lib",
35+
"@org_tensorflow//tensorflow/core/framework:tensor",
3436
"@org_tensorflow//tensorflow/core/platform:jpeg",
3537
],
3638
)

tensorflow_serving/model_servers/test_util/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ cc_library(
109109
":storage_path_error_injecting_source_adapter_cc_proto",
110110
"//tensorflow_serving/core:source_adapter",
111111
],
112+
alwayslink = 1,
112113
)
113114

114115
serving_proto_library(

tensorflow_serving/repo.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def _tensorflow_http_archive(ctx):
1818
git_commit = ctx.attr.git_commit
1919
sha256 = ctx.attr.sha256
2020
patch = getattr(ctx.attr, "patch", None)
21+
patch_cmds = getattr(ctx.attr, "patch_cmds", [])
2122

2223
override_git_commit = ctx.os.environ.get(_TF_REVISION)
2324
if override_git_commit:
@@ -37,12 +38,17 @@ def _tensorflow_http_archive(ctx):
3738
)
3839
if patch:
3940
ctx.patch(patch, strip = 1)
41+
for cmd in patch_cmds:
42+
res = ctx.execute(["bash", "-c", cmd])
43+
if res.return_code != 0:
44+
fail("Failed to execute patch_cmd %s: %s" % (cmd, res.stderr))
4045

4146
tensorflow_http_archive = repository_rule(
4247
implementation = _tensorflow_http_archive,
4348
attrs = {
4449
"git_commit": attr.string(mandatory = True),
4550
"sha256": attr.string(mandatory = True),
4651
"patch": attr.label(),
52+
"patch_cmds": attr.string_list(),
4753
},
4854
)

tensorflow_serving/resources/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cc_library(
5050
deps = [
5151
":resources_cc_proto",
5252
"@com_google_absl//absl/container:flat_hash_set",
53+
"@com_google_absl//absl/log:check",
5354
"@org_tensorflow//tensorflow/core:lib",
5455
],
5556
)

tensorflow_serving/servables/tensorflow/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ cc_library(
971971
"//tensorflow_serving/apis:predict_cc_proto",
972972
"//tensorflow_serving/apis:prediction_log_cc_proto",
973973
"//tensorflow_serving/apis:regression_cc_proto",
974+
"@com_google_protobuf//:protobuf",
974975
"@org_tensorflow//tensorflow/cc/saved_model:constants",
975976
"@org_tensorflow//tensorflow/cc/saved_model:signature_constants",
976977
"@org_tensorflow//tensorflow/core:lib",

tensorflow_serving/test_util/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ cc_binary(
4747
"@com_google_absl//absl/flags:flag",
4848
"@com_google_absl//absl/flags:parse",
4949
"@com_google_absl//absl/strings",
50+
"@local_xla//xla/tsl/lib/histogram",
51+
"@local_xla//xla/tsl/platform:env",
5052
"@org_tensorflow//tensorflow/core:lib",
51-
"@org_tensorflow//tensorflow/core/platform:env",
5253
],
5354
)

tensorflow_serving/tools/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ARG TF_SERVING_VERSION=latest
1616
ARG TF_SERVING_BUILD_IMAGE=tensorflow/serving:${TF_SERVING_VERSION}-devel
1717

1818
FROM ${TF_SERVING_BUILD_IMAGE} as build_image
19-
FROM ubuntu:20.04
19+
FROM ubuntu:22.04@sha256:eb29ed27b0821dca09c2e28b39135e185fc1302036427d5f4d70a41ce8fd7659
2020

2121
ARG TF_SERVING_VERSION_GIT_BRANCH=master
2222
ARG TF_SERVING_VERSION_GIT_COMMIT=head

tensorflow_serving/tools/docker/Dockerfile.devel

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
FROM ubuntu:20.04 as base_build
14+
FROM ubuntu:22.04@sha256:eb29ed27b0821dca09c2e28b39135e185fc1302036427d5f4d70a41ce8fd7659 as base_build
15+
1516

1617
ARG TF_SERVING_VERSION_GIT_BRANCH=master
1718
ARG TF_SERVING_VERSION_GIT_COMMIT=HEAD
@@ -27,37 +28,35 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2728
ca-certificates \
2829
curl \
2930
git \
30-
gcc-10 \
31-
g++-10 \
3231
libcurl3-dev \
3332
libfreetype6-dev \
3433
libpng-dev \
3534
libtool \
3635
libzmq3-dev \
3736
mlocate \
38-
openjdk-8-jdk\
39-
openjdk-8-jre-headless \
37+
openjdk-11-jdk \
38+
openjdk-11-jre-headless \
4039
pkg-config \
41-
python-dev \
40+
python3-dev \
4241
software-properties-common \
4342
swig \
4443
unzip \
4544
wget \
4645
zip \
4746
zlib1g-dev \
48-
python3-distutils \
47+
python3-setuptools \
4948
&& \
5049
apt-get clean && \
5150
rm -rf /var/lib/apt/lists/*
5251

53-
# Install python 3.10.
54-
RUN add-apt-repository ppa:deadsnakes/ppa && \
55-
apt-get update && apt-get install -y \
52+
# Install python 3.10 (Native on Ubuntu 22.04).
53+
RUN apt-get update && apt-get install -y \
5654
python3.10 python3.10-dev python3-pip python3.10-venv && \
5755
rm -rf /var/lib/apt/lists/* && \
5856
python3.10 -m pip install pip --upgrade && \
5957
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 0
6058

59+
6160
# Make python3.10 the default python version
6261
# If updating default python version, also update version in the WORKSPACE file.
6362
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 0
@@ -107,7 +106,6 @@ RUN bazel build --color=yes --curses=yes \
107106
--verbose_failures \
108107
--output_filter=DONT_MATCH_ANYTHING \
109108
${TF_SERVING_BUILD_OPTIONS} \
110-
--config=kokoro \
111109
tensorflow_serving/model_servers:tensorflow_model_server && \
112110
cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server \
113111
/usr/local/bin/
@@ -118,7 +116,6 @@ RUN bazel build --color=yes --curses=yes \
118116
--verbose_failures \
119117
--output_filter=DONT_MATCH_ANYTHING \
120118
${TF_SERVING_BUILD_OPTIONS} \
121-
--config=kokoro \
122119
tensorflow_serving/tools/pip_package:build_pip_package && \
123120
bazel-bin/tensorflow_serving/tools/pip_package/build_pip_package \
124121
/tmp/pip && \

0 commit comments

Comments
 (0)