Skip to content

Commit

Permalink
Merge pull request #56097 from mseth10:master-arm
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 450065584
  • Loading branch information
tensorflower-gardener authored and mihaimaruseac committed May 20, 2022
1 parent 21bd9f7 commit 7b3588f
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 40 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/arm-cd.yml
@@ -0,0 +1,55 @@
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

name: ARM CD

on:
push:
tags:
- v2.**
schedule:
- cron: '0 8 * * *'

jobs:
build:
runs-on: [self-hosted, linux, ARM64]
strategy:
matrix:
pyver: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Stop old running containers (if any)
shell: bash
run: |
running_containers=$(docker ps -q) && \
if [[ $running_containers == "" ]]; then
echo "No running containers";
else
echo "Running container(s) found" && \
docker stop $running_containers;
fi
docker container prune -f
- name: Clean repository
shell: bash
run: find /home/ubuntu/actions-runner/_work/tensorflow/tensorflow/. -name . -o -prune -exec sudo rm -rf -- {} + || true
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and test pip wheel
shell: bash
run: |
CI_DOCKER_BUILD_EXTRA_PARAMS='--build-arg py_major_minor_version=${{ matrix.pyver }}' \
./tensorflow/tools/ci_build/ci_build.sh cpu.arm64 bash tensorflow/tools/ci_build/rel/ubuntu/cpu_arm64_pip.sh
- name: Upload pip wheel to PyPI
shell: bash
run: python3 -m twine upload --verbose /home/ubuntu/actions-runner/_work/tensorflow/tensorflow/whl/* -u "__token__" -p ${{ secrets.AWS_PYPI_ACCOUNT_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/arm-ci.yml
@@ -0,0 +1,57 @@
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

name: ARM CI

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
- r2.**

jobs:
build:
runs-on: [self-hosted, linux, ARM64]
strategy:
matrix:
pyver: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Stop old running containers (if any)
shell: bash
run: |
running_containers=$(docker ps -q) && \
if [[ $running_containers == "" ]]; then
echo "No running containers";
else
echo "Running container(s) found" && \
docker stop $running_containers;
fi
docker container prune -f
- name: Clean repository
shell: bash
run: find /home/ubuntu/actions-runner/_work/tensorflow/tensorflow/. -name . -o -prune -exec sudo rm -rf -- {} + || true
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and test pip wheel
shell: bash
run: |
CI_DOCKER_BUILD_EXTRA_PARAMS='--build-arg py_major_minor_version=${{ matrix.pyver }}' \
./tensorflow/tools/ci_build/ci_build.sh cpu.arm64 bash tensorflow/tools/ci_build/rel/ubuntu/cpu_arm64_pip.sh
- name: Upload pip wheel to GitHub
uses: actions/upload-artifact@v3
with:
name: tensorflow_py${{ matrix.pyver }}_wheel
path: /home/ubuntu/actions-runner/_work/tensorflow/tensorflow/whl/*.whl
40 changes: 40 additions & 0 deletions tensorflow/tools/ci_build/Dockerfile.cpu.arm64
@@ -0,0 +1,40 @@
FROM quay.io/pypa/manylinux2014_aarch64

RUN yum -y check-update || true && \
yum install -y epel-release && \
yum install -y \
sudo \
wget \
openssl-devel \
libffi-devel \
java-1.8.0-openjdk-devel \
bzip2-devel \
gdbm-devel \
ncurses-devel \
nss-devel \
readline-devel \
sqlite-devel \
hdf5-devel && \
yum clean all

COPY install/install_bazel.sh /install/
RUN /install/install_bazel.sh

ARG py_major_minor_version

ENV TF_PYTHON_VERSION=python${py_major_minor_version}
ENV PYTHON_BIN_PATH=/usr/local/bin/${TF_PYTHON_VERSION}

RUN ln -s ${PYTHON_BIN_PATH} /usr/local/bin/python && \
ln -s ${PYTHON_BIN_PATH} /usr/local/bin/python3

RUN curl -o /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
python /tmp/get-pip.py && \
rm -f /tmp/get-pip.py

RUN export PYTHON_VERSION=$(python -c 'import platform; print(platform.python_version())') && \
ln -s /opt/_internal/cpython-$PYTHON_VERSION/bin/pip3 /usr/local/bin/pip${py_major_minor_version} && \
ln -s /opt/_internal/cpython-$PYTHON_VERSION/bin/pip3 /usr/local/bin/pip3 && \
ln -s /opt/_internal/cpython-$PYTHON_VERSION/bin/pip /usr/local/bin/pip

RUN pip3 install packaging
8 changes: 3 additions & 5 deletions tensorflow/tools/ci_build/builds/pip_new.sh
Expand Up @@ -762,12 +762,10 @@ if [[ ${OS_TYPE} == "ubuntu" ]] && \
for WHL_PATH in $(ls ${PIP_WHL_DIR}/*.whl); do
# Repair the wheels for cpu manylinux2010/manylinux2014
echo "auditwheel repairing ${WHL_PATH}"
auditwheel repair --plat ${AUDITWHEEL_TARGET_PLAT}_x86_64 -w "${WHL_DIR}" "${WHL_PATH}"
auditwheel repair --plat ${AUDITWHEEL_TARGET_PLAT}_$(uname -m) -w "${WHL_DIR}" "${WHL_PATH}"

WHL_BASE_NAME=$(basename "${WHL_PATH}")
AUDITED_WHL_NAME="${WHL_DIR}"/$(echo "${WHL_BASE_NAME//linux/${AUDITWHEEL_TARGET_PLAT}}")
if [[ -f ${AUDITED_WHL_NAME} ]]; then
WHL_PATH=${AUDITED_WHL_NAME}
if [[ $(ls ${WHL_DIR} | grep ${AUDITWHEEL_TARGET_PLAT} | wc -l) == 1 ]] ; then
WHL_PATH=${WHL_DIR}/$(ls ${WHL_DIR} | grep ${AUDITWHEEL_TARGET_PLAT})
echo "Repaired ${AUDITWHEEL_TARGET_PLAT} wheel file at: ${WHL_PATH}"
else
die "WARNING: Cannot find repaired wheel."
Expand Down
64 changes: 35 additions & 29 deletions tensorflow/tools/ci_build/builds/with_the_same_user
Expand Up @@ -27,39 +27,45 @@ set -e

COMMAND=("$@")

if ! touch /this_is_writable_file_system; then
echo "You can't write to your filesystem!"
echo "If you are in Docker you should check you do not have too many images" \
"with too many files in them. Docker has some issue with it."
exit 1
if [[ $(awk -F= '/^NAME/{print $2}' /etc/os-release) == *"CentOS"* ]]; then
${COMMAND[@]}
else
rm /this_is_writable_file_system
fi

if [ -n "${CI_BUILD_USER_FORCE_BADNAME}" ]; then
ADDUSER_OPTS="--force-badname"
fi
if ! touch /this_is_writable_file_system; then
echo "You can't write to your filesystem!"
echo "If you are in Docker you should check you do not have too many images" \
"with too many files in them. Docker has some issue with it."
exit 1
else
rm /this_is_writable_file_system
fi

apt-get install sudo
if [ -n "${CI_BUILD_USER_FORCE_BADNAME}" ]; then
ADDUSER_OPTS="--force-badname"
fi

getent group "${CI_BUILD_GID}" || addgroup ${ADDUSER_OPTS} --gid "${CI_BUILD_GID}" "${CI_BUILD_GROUP}"
getent passwd "${CI_BUILD_UID}" || adduser ${ADDUSER_OPTS} \
--gid "${CI_BUILD_GID}" --uid "${CI_BUILD_UID}" \
--gecos "${CI_BUILD_USER} (generated by with_the_same_user script)" \
--disabled-password --home "${CI_BUILD_HOME}" --quiet "${CI_BUILD_USER}"
usermod -a -G sudo "${CI_BUILD_USER}"
echo "${CI_BUILD_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-nopasswd-sudo
apt-get install sudo

if [[ "${TF_NEED_ROCM}" -eq 1 ]]; then
# ROCm requires the video group in order to use the GPU for compute. If it
# exists on the host, add it to the container.
getent group video || addgroup video && adduser "${CI_BUILD_USER}" video
fi
getent group "${CI_BUILD_GID}" || addgroup ${ADDUSER_OPTS} --gid "${CI_BUILD_GID}" "${CI_BUILD_GROUP}"
getent passwd "${CI_BUILD_UID}" || adduser ${ADDUSER_OPTS} \
--gid "${CI_BUILD_GID}" --uid "${CI_BUILD_UID}" \
--gecos "${CI_BUILD_USER} (generated by with_the_same_user script)" \
--disabled-password --home "${CI_BUILD_HOME}" --quiet "${CI_BUILD_USER}"
usermod -a -G sudo "${CI_BUILD_USER}"
echo "${CI_BUILD_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-nopasswd-sudo

if [ -e /root/.bazelrc ]; then
cp /root/.bazelrc "${CI_BUILD_HOME}/.bazelrc"
chown "${CI_BUILD_UID}:${CI_BUILD_GID}" "${CI_BUILD_HOME}/.bazelrc"
fi
if [[ "${TF_NEED_ROCM}" -eq 1 ]]; then
# ROCm requires the video group in order to use the GPU for compute. If it
# exists on the host, add it to the container.
getent group video || addgroup video && adduser "${CI_BUILD_USER}" video
fi

sudo -u "#${CI_BUILD_UID}" --preserve-env "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" \
"HOME=${CI_BUILD_HOME}" ${COMMAND[@]}
if [ -e /root/.bazelrc ]; then
cp /root/.bazelrc "${CI_BUILD_HOME}/.bazelrc"
chown "${CI_BUILD_UID}:${CI_BUILD_GID}" "${CI_BUILD_HOME}/.bazelrc"
fi

sudo -u "#${CI_BUILD_UID}" --preserve-env "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" \
"HOME=${CI_BUILD_HOME}" ${COMMAND[@]}

fi
15 changes: 10 additions & 5 deletions tensorflow/tools/ci_build/install/install_bazel.sh
Expand Up @@ -29,12 +29,17 @@ set -e
# Install bazel.
mkdir -p /bazel
cd /bazel
if [[ ! -f "bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" ]]; then
curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
if [[ $(uname -m) == "aarch64" ]]; then
curl -o /usr/local/bin/bazel -fSsL https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-linux-arm64
chmod +x /usr/local/bin/bazel
else
if [[ ! -f "bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" ]]; then
curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
fi
chmod +x /bazel/bazel-*.sh
/bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
fi
chmod +x /bazel/bazel-*.sh
/bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh

# Enable bazel auto completion.
echo "source /usr/local/lib/bazel/bin/bazel-complete.bash" >> ~/.bashrc
96 changes: 96 additions & 0 deletions tensorflow/tools/ci_build/rel/ubuntu/cpu_arm64_pip.sh
@@ -0,0 +1,96 @@
#!/bin/bash
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

set -e
set -x

source tensorflow/tools/ci_build/release/common.sh

# Update bazel
install_bazelisk

# Env vars used to avoid interactive elements of the build.
export HOST_C_COMPILER=(which gcc)
export HOST_CXX_COMPILER=(which g++)
export TF_ENABLE_XLA=1
export TF_DOWNLOAD_CLANG=0
export TF_SET_ANDROID_WORKSPACE=0
export TF_NEED_MPI=0
export TF_NEED_ROCM=0
export TF_NEED_GCP=0
export TF_NEED_S3=0
export TF_NEED_OPENCL_SYCL=0
export TF_NEED_CUDA=0
export TF_NEED_HDFS=0
export TF_NEED_OPENCL=0
export TF_NEED_JEMALLOC=1
export TF_NEED_VERBS=0
export TF_NEED_AWS=0
export TF_NEED_GDR=0
export TF_NEED_OPENCL_SYCL=0
export TF_NEED_COMPUTECPP=0
export TF_NEED_KAFKA=0
export TF_NEED_TENSORRT=0

# Export required variables for running pip_new.sh
export OS_TYPE="UBUNTU"
export CONTAINER_TYPE="CPU"

# Get the default test targets for bazel.
source tensorflow/tools/ci_build/build_scripts/DEFAULT_TEST_TARGETS.sh

# Set python version string
py_ver=$(python -c 'import sys; print(str(sys.version_info.major)+str(sys.version_info.minor))')

# Export optional variables for running pip_new.sh
export TF_BUILD_FLAGS="--config=mkl_aarch64 --copt=-mtune=generic --copt=-march=armv8-a \
--copt=-O3 --copt=-fopenmp --copt=-flax-vector-conversions --linkopt=-lgomp"
export TF_TEST_FLAGS="${TF_BUILD_FLAGS} \
--test_env=TF_ENABLE_ONEDNN_OPTS=1 --test_env=TF2_BEHAVIOR=1 --test_lang_filters=py \
--define=no_tensorflow_py_deps=true --verbose_failures=true --test_keep_going"
export TF_TEST_TARGETS="${DEFAULT_BAZEL_TARGETS} \
-//tensorflow/lite/... \
-//tensorflow/compiler/mlir/lite/tests:const-fold.mlir.test \
-//tensorflow/compiler/mlir/lite/tests:prepare-tf.mlir.test \
-//tensorflow/python:nn_grad_test \
-//tensorflow/python:dequantize_op_test \
-//tensorflow/python:quantized_ops_test \
-//tensorflow/python/data/experimental/kernel_tests/service:cross_trainer_cache_test \
-//tensorflow/python/eager:forwardprop_test \
-//tensorflow/python/framework:node_file_writer_test \
-//tensorflow/python/grappler:memory_optimizer_test \
-//tensorflow/python/kernel_tests/linalg:linear_operator_householder_test \
-//tensorflow/python/kernel_tests/linalg:linear_operator_inversion_test \
-//tensorflow/python/kernel_tests/linalg:linear_operator_block_diag_test \
-//tensorflow/python/kernel_tests/linalg:linear_operator_block_lower_triangular_test \
-//tensorflow/python/kernel_tests/linalg:linear_operator_kronecker_test \
-//tensorflow/python/kernel_tests/math_ops:batch_matmul_op_test \
-//tensorflow/python/kernel_tests/nn_ops:conv_ops_test \
-//tensorflow/python/kernel_tests/nn_ops:conv2d_backprop_filter_grad_test \
-//tensorflow/python/kernel_tests/nn_ops:conv3d_backprop_filter_v2_grad_test \
-//tensorflow/python/kernel_tests/nn_ops:atrous_conv2d_test \
-//tensorflow/python/ops/parallel_for:math_test"
export TF_PIP_TESTS="test_pip_virtualenv_clean"
export TF_TEST_FILTER_TAGS="-no_oss,-oss_serial,-no_oss_py${py_ver},-gpu,-tpu,-benchmark-test,-v1only,-no_aarch64,-requires-gpu"
export IS_NIGHTLY=0 # Not nightly; uncomment if building from tf repo.
export TF_PROJECT_NAME="aws_tensorflow_cpu"
export TF_PIP_TEST_ROOT="pip_test"
export TF_AUDITWHEEL_TARGET_PLAT="manylinux2014"

source tensorflow/tools/ci_build/builds/pip_new.sh

# remove duplicate wheel and copy wheel to mounted volume for local access
rm -rf /tensorflow/pip_test/whl/*linux_aarch64.whl && cp -r /tensorflow/pip_test/whl .
7 changes: 6 additions & 1 deletion tensorflow/tools/ci_build/release/common.sh
Expand Up @@ -62,7 +62,12 @@ function install_bazelisk {
date
case "$(uname -s)" in
Darwin) local name=bazelisk-darwin-amd64 ;;
Linux) local name=bazelisk-linux-amd64 ;;
Linux)
case "$(uname -m)" in
x86_64) local name=bazelisk-linux-amd64 ;;
aarch64) local name=bazelisk-linux-arm64 ;;
*) die "Unknown machine type: $(uname -m)" ;;
esac ;;
*) die "Unknown OS: $(uname -s)" ;;
esac
mkdir -p "$HOME/bin"
Expand Down

0 comments on commit 7b3588f

Please sign in to comment.