-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker build scripts and enable aarch64 pip wheels.
Also enable python 3.12 builds. Usage: ``` bash oss_scripts/docker_builds.sh ``` or to build for a single python version, ``` PYTHON_VERSION=3.12 bash oss_scripts/docker_builds.sh ``` PiperOrigin-RevId: 692953635
- Loading branch information
1 parent
9474dd9
commit 5180fd9
Showing
16 changed files
with
2,911 additions
and
1,552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Constructs the environment within which we will build the tensorflow-text | ||
# pip wheels. | ||
|
||
FROM linaro/tensorflow-arm64-build:2.16-multipython | ||
LABEL maintainer="TensorFlow-Text team <[email protected]>" | ||
|
||
ARG PYTHON_VERSION | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV PYTHON_BIN_PATH=/usr/bin/python${PYTHON_VERSION} | ||
|
||
# Install supplementary Python interpreters | ||
RUN ln -s ${PYTHON_BIN_PATH} /usr/local/bin/python && \ | ||
ln -s ${PYTHON_BIN_PATH} /usr/local/bin/python3 && \ | ||
ln -s ${PYTHON_BIN_PATH} /usr/bin/python | ||
|
||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
apt update && \ | ||
apt install -yqq \ | ||
apt-utils \ | ||
build-essential \ | ||
checkinstall \ | ||
libffi-dev | ||
|
||
# Install pip dependencies needed for tensorflow-text | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
${PYTHON_BIN_PATH} -m pip install -U pip && \ | ||
${PYTHON_BIN_PATH} -m pip install -U \ | ||
absl-py \ | ||
auditwheel \ | ||
etils[epath] \ | ||
patchelf \ | ||
setuptools \ | ||
twine \ | ||
wheel; | ||
|
||
WORKDIR "/tmp/tensorflow_text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Constructs the environment within which we will build the tensorflow-text | ||
# pip wheels. | ||
|
||
ARG PYTHON_VERSION | ||
FROM tensorflow/build:2.18-python${PYTHON_VERSION} | ||
LABEL maintainer="TensorFlow-Text team <[email protected]>" | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install supplementary Python interpreters | ||
RUN mkdir /tmp/python | ||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
apt update && \ | ||
apt install -yqq \ | ||
apt-utils \ | ||
build-essential \ | ||
checkinstall \ | ||
libffi-dev | ||
|
||
# Install pip dependencies needed for tensorflow text. | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
python${PYTHON_VERSION} -m pip install -U pip && \ | ||
python${PYTHON_VERSION} -m pip install -U \ | ||
absl-py \ | ||
auditwheel \ | ||
etils[epath] \ | ||
patchelf \ | ||
setuptools \ | ||
twine \ | ||
wheel; | ||
|
||
WORKDIR "/tmp/tensorflow_text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# This script builds a docker container, and pip wheels for all supported | ||
# Python versions. Run from the root tensorflow-text directory: | ||
# | ||
# ./oss_scripts/docker_builds.sh | ||
|
||
set -e -x | ||
|
||
# If a specific PYTHON_VERSION is specified, only build that one. | ||
# Otherwisebuild all supported versions. | ||
python_versions=("3.9" "3.10" "3.11" "3.12") | ||
if [[ ! -z ${PYTHON_VERSION+x} ]]; then | ||
python_versions=("$PYTHON_VERSION") | ||
fi | ||
|
||
# Clean previous images. | ||
for python_version in ${python_versions[@]} | ||
do | ||
docker rmi -f tensorflow_text:${python_version} || true | ||
done | ||
|
||
arch=$(uname -m) | ||
build_args=() | ||
if [ "$arch" == "x86_64" ]; then | ||
build_args+=("--config=release_cpu_linux") | ||
build_args+=("[email protected]_config_platform//:platform") | ||
auditwheel_platform="manylinux2014_x86_64" | ||
elif [ "$arch" == "aarch64" ]; then | ||
build_args+=("--crosstool_top=@ml2014_aarch64_config_aarch64//crosstool:toolchain") | ||
auditwheel_platform="manylinux2014_aarch64" | ||
fi | ||
|
||
# Build wheel for each Python version. | ||
for python_version in ${python_versions[@]} | ||
do | ||
DOCKER_BUILDKIT=1 docker build --progress=plain --no-cache \ | ||
--build-arg HERMETIC_PYTHON_VERSION=${python_version} --build-arg PYTHON_VERSION=${python_version} \ | ||
-t tensorflow_text:${python_version} - < "oss_scripts/build.Dockerfile.${arch}" | ||
|
||
docker run --rm -a stdin -a stdout -a stderr \ | ||
--env PYTHON_VERSION=${python_version} \ | ||
--env HERMETIC_PYTHON_VERSION=${python_version} \ | ||
--env BUILD_ARGS=${build_args} \ | ||
--env AUDITWHEEL_PLATFORM=${auditwheel_platform} \ | ||
--env IS_NIGHTLY=${IS_NIGHTLY} \ | ||
-v $PWD:/tmp/tensorflow_text \ | ||
--name tensorflow_text tensorflow_text:${python_version} \ | ||
bash oss_scripts/run_build.sh | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# ai-edge-litert | ||
setuptools==70.0.0 | ||
tensorflow | ||
tf-keras | ||
tensorflow-datasets | ||
|
Oops, something went wrong.