Skip to content

Commit 61f0b2b

Browse files
committed
Update to TF 2.9 and also update build scripts to use TF SIG Build container image to make the binary compatible to TF 2.9+.
TF 2.9+ uses cxx11 ABI[1] and s2t should be compiled with cxx11 ABI enabled. To make things simpler, I changed the base image for the build from plain manylinux to TF SIG Build image. The image contains all required toolset already. One caveat is that the `gold` linker included in the image fails to link with following error: ``` /dt9/usr/bin/../lib/gcc/x86_64-pc-linux-gnu/9/crtend.o(.gnu.build.attributes+0x14): error: relocation refers to local symbol "" [2], which is defined in a discarded section section group signature: "(null)" ``` So I upgraded binutils(which includes gold) to 2.35.1 and it worked fine. Also deleted redundant flatbuffer dependency definition. We can use the flatbuffer definition in tensorflow and avoid the version mismatch. [1] https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html PiperOrigin-RevId: 449859520
1 parent 483a115 commit 61f0b2b

File tree

13 files changed

+84
-94
lines changed

13 files changed

+84
-94
lines changed

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ build --apple_platform_type=macos
2424
# Enable using platform specific build settings
2525
build --enable_platform_specific_config
2626

27+
# Enable using 'cc_shared_library' rule.
28+
build --experimental_cc_shared_library
29+
2730
# Flag to enable remote config
2831
common --experimental_repo_remote_exec
2932

@@ -33,8 +36,10 @@ build:macos --copt=-w
3336

3437
# By default, build TF in C++ 14 mode.
3538
build:linux --cxxopt=-std=c++14
39+
build:linux --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=1
3640
build:linux --host_cxxopt=-std=c++14
3741
build:macos --cxxopt=-std=c++14
42+
build:macos --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=1
3843
build:macos --host_cxxopt=-std=c++14
3944

4045
# Suppress all warning messages.

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.1.1

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ command:
4747
pip install --extra-index-url https://pypi-nightly.tensorflow.org/simple struct2tensor
4848
```
4949

50-
This will install the nightly packages for the major dependencies of Fairness
51-
Indicators such as TensorFlow Metadata (TFMD).
50+
This will install the nightly packages for the major dependencies of
51+
struct2tensor such as TensorFlow Metadata (TFMD).
5252

5353
## Creating a PIP package.
5454

@@ -73,26 +73,16 @@ cd ~/struct2tensor
7373
### Use docker-compose
7474
Install [docker-compose](https://docs.docker.com/compose/).
7575

76-
Use it to build a pip wheel for Python 3.6 with tensorflow version 2:
76+
Use it to build a pip wheel for Python 3.7 with tensorflow version 2:
7777

7878
```bash
79-
docker-compose build manylinux2010
80-
docker-compose run -e PYTHON_VERSION=36 -e TF_VERSION=RELEASED_TF_2 manylinux2010
81-
```
82-
83-
Or build a pip wheel for Python 3.7 with tensorflow version 2 (note that if you
84-
run one of these docker-compose commands after the other, the second will erase
85-
the result from the first):
86-
87-
```bash
88-
docker-compose build manylinux2010
89-
docker-compose run -e PYTHON_VERSION=37 -e TF_VERSION=RELEASED_TF_2 manylinux2010
79+
docker-compose build --build-arg PYTHON_VERSION=3.7 manylinux2014
80+
docker-compose run -e TF_VERSION=RELEASED_TF_2 manylinux2014
9081
```
9182

9283
This will create a manylinux package in the ~/struct2tensor/dist directory.
9384

9485

95-
9686
## Creating a static library
9787

9888
In order to construct a static library for tensorflow-serving, we run:

RELEASE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44

55
## Major Features and Improvements
66

7+
* Linux wheels now specifically conform to
8+
[manylinux2014](https://peps.python.org/pep-0599/), an upgrade from
9+
manylinux2010. This is aligned with TensorFlow 2.9 requirement.
10+
711
## Bug Fixes and Other Changes
812

13+
* Depends on `tensorflow>=2.9.0,<2.10`.
14+
915
## Breaking Changes
1016

1117
## Deprecations

WORKSPACE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ tf_configure(name = "local_config_tf")
4141
# 3. Request the new archive to be mirrored on mirror.bazel.build for more
4242
# reliable downloads.
4343

44-
_TENSORFLOW_GIT_COMMIT = "3f878cff5b698b82eea85db2b60d65a2e320850e" # tf 2.8.0
45-
_TENSORFLOW_ARCHIVE_SHA256 = "21d919ad6d96fcc0477c8d4f7b1f7e4295aaec2986e035551ed263c2b1cd52ee"
44+
_TENSORFLOW_GIT_COMMIT = "8a20d54a3c1bfa38c03ea99a2ad3c1b0a45dfa95" # tf 2.9.0
45+
_TENSORFLOW_ARCHIVE_SHA256 = "5b3cde72888d680e4b6162351d614d6ac2d3ef44032e91b5838a9647ecc387a6"
4646

4747
http_archive(
4848
name = "org_tensorflow",
4949
sha256 = _TENSORFLOW_ARCHIVE_SHA256,
5050
urls = [
51-
"https://mirror.bazel.build/github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
5251
"https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
5352
],
5453
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,

docker-compose.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ version: '3.1'
1919
# We mount the struct2tensor project root at /struct2tensor (which is the WORKDIR of the image)
2020
# in the container.
2121
#
22-
# The expected environment variables to be set are PYTHON_VERSION and TF_VERSION
23-
# Valid PYTHON_VERSION are 35|36|37|27
22+
# We need to set PYTHON_VERSION in `build` command which is used to pick the
23+
# base TF SIG Build image.
24+
# The TF_VERSION environment variables is expected when run the pipeline
2425
# Valid TF_VERSION are NIGHTLY_TF|NIGHTLY_TF_2|RELEASED_TF|PRERELEASED_TF|RELEASED_TF_2|PRERELEASED_TF_2
2526
# Sample usage:
26-
# docker-compose build manylinux2010
27-
# docker-compose run -e PYTHON_VERSION=36 -e TF_VERSION=NIGHTLY_TF manylinux2010
27+
# docker-compose build --build-arg PYTHON_VERSION=3.7 manylinux2014
28+
# docker-compose run -e TF_VERSION=NIGHTLY_TF manylinux2014
2829

2930
services:
30-
manylinux2010:
31-
image: struct2tensor-build:manylinux2010
31+
manylinux2014:
32+
image: struct2tensor-build:manylinux2014
3233
build:
3334
context: .
34-
dockerfile: struct2tensor/tools/docker_build/Dockerfile.manylinux2010
35+
dockerfile: struct2tensor/tools/docker_build/Dockerfile.manylinux2014
3536
volumes:
3637
- .:/struct2tensor:delegated

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def select_constraint(default, nightly=None, git_master=None):
7575
packages=find_packages(),
7676
install_requires=[
7777
'protobuf>=3.13,<4',
78-
'tensorflow>=2.8.0,<2.9',
78+
'tensorflow>=2.9.0,<2.10',
7979
'tensorflow-metadata' + select_constraint(
8080
default='>=1.8.0,<1.9.0',
8181
nightly='>=1.9.0.dev',

struct2tensor/struct2tensor.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ def s2t_proto_library(
7171

7272
DYNAMIC_COPTS = [
7373
"-pthread",
74-
"-std=c++14",
75-
"-D_GLIBCXX_USE_CXX11_ABI=0",
7674
]
7775

7876
DYNAMIC_DEPS = ["@local_config_tf//:libtensorflow_framework", "@local_config_tf//:tf_header_lib"]

struct2tensor/tools/docker_build/Dockerfile.manylinux2010

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Dockerfile for building a manylinux2014 struct2tensor wheel.
16+
ARG PYTHON_VERSION
17+
FROM tensorflow/build:latest-python${PYTHON_VERSION}
18+
WORKDIR /struct2tensor
19+
20+
# Uses manylinux2014 compatible devtoolset. See below for the detail:
21+
# https://github.com/tensorflow/build/blob/master/tf_sig_build_dockerfiles/builder.devtoolset/build_devtoolset.sh
22+
ENV CC=/dt9/usr/bin/gcc
23+
24+
# tensorflow/build images already contains nightly packages. Clean them up.
25+
RUN pip uninstall -y tf-nightly tb-nightly tf-estimator-nightly keras-nightly
26+
27+
RUN pip install auditwheel
28+
29+
# Update binutils to avoid linker(gold) issue. See b/227299577#comment9
30+
RUN wget http://old-releases.ubuntu.com/ubuntu/pool/main/b/binutils/binutils_2.35.1-1ubuntu1_amd64.deb \
31+
&& wget http://old-releases.ubuntu.com/ubuntu/pool/main/b/binutils/binutils-x86-64-linux-gnu_2.35.1-1ubuntu1_amd64.deb \
32+
&& wget http://old-releases.ubuntu.com/ubuntu/pool/main/b/binutils/binutils-common_2.35.1-1ubuntu1_amd64.deb \
33+
&& wget http://old-releases.ubuntu.com/ubuntu/pool/main/b/binutils/libbinutils_2.35.1-1ubuntu1_amd64.deb
34+
RUN dpkg -i binutils_2.35.1-1ubuntu1_amd64.deb \
35+
binutils-x86-64-linux-gnu_2.35.1-1ubuntu1_amd64.deb \
36+
binutils-common_2.35.1-1ubuntu1_amd64.deb \
37+
libbinutils_2.35.1-1ubuntu1_amd64.deb
38+
39+
CMD ["struct2tensor/tools/docker_build/build_manylinux.sh"]

0 commit comments

Comments
 (0)