chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
load("@xla//third_party/rules_python/python:py_binary.bzl", "py_binary")
load("//tensorflow:tf_version.bzl", "TF_VERSION")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
licenses = ["notice"],
)
py_binary(
name = "calculate_full_version",
srcs = ["calculate_full_version.py"],
args = ["--wheel-version={}".format(TF_VERSION)],
strict_deps = True,
)
exports_files(
srcs = glob(["Dockerfile.*"]),
visibility = ["//visibility:public"],
)
@@ -0,0 +1,71 @@
# Copyright 2026 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.
# ==============================================================================
FROM ubuntu:16.04
LABEL maintainer="Jan Prach <jendap@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
RUN /install/install_bazel.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
# Install extra libraries for android sdk.
RUN apt-get update && apt-get install -y \
python-numpy \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Android SDK and NDK root directory workaround. For details see
# https://github.com/bazelbuild/bazel/issues/714#issuecomment-166735874
ENV ANDROID_DEV_HOME /android
RUN mkdir -p ${ANDROID_DEV_HOME}
# Install Android SDK.
ENV ANDROID_SDK_FILENAME tools_r25.2.5-linux.zip
ENV ANDROID_SDK_URL https://dl.google.com/android/repository/${ANDROID_SDK_FILENAME}
ENV ANDROID_API_LEVEL 23
ENV ANDROID_NDK_API_LEVEL 21
# Build Tools Version liable to change.
ENV ANDROID_BUILD_TOOLS_VERSION 28.0.0
ENV ANDROID_SDK_HOME ${ANDROID_DEV_HOME}/sdk
ENV PATH ${PATH}:${ANDROID_SDK_HOME}/tools:${ANDROID_SDK_HOME}/platform-tools
RUN cd ${ANDROID_DEV_HOME} && \
wget -q ${ANDROID_SDK_URL} && \
unzip ${ANDROID_SDK_FILENAME} -d android-sdk-linux && \
rm ${ANDROID_SDK_FILENAME} && \
bash -c "ln -s ${ANDROID_DEV_HOME}/android-sdk-* ${ANDROID_SDK_HOME}" && \
echo y | android update sdk --no-ui -a --filter tools,platform-tools,android-${ANDROID_API_LEVEL},build-tools-${ANDROID_BUILD_TOOLS_VERSION}
# Install Android NDK.
ENV ANDROID_NDK_FILENAME android-ndk-r18b-linux-x86_64.zip
ENV ANDROID_NDK_URL https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}
ENV ANDROID_NDK_HOME ${ANDROID_DEV_HOME}/ndk
ENV PATH ${PATH}:${ANDROID_NDK_HOME}
RUN cd ${ANDROID_DEV_HOME} && \
wget -q ${ANDROID_NDK_URL} && \
unzip ${ANDROID_NDK_FILENAME} -d ${ANDROID_DEV_HOME} && \
rm ${ANDROID_NDK_FILENAME} && \
bash -c "ln -s ${ANDROID_DEV_HOME}/android-ndk-* ${ANDROID_NDK_HOME}"
# Make android ndk executable to all users.
RUN chmod -R go=u ${ANDROID_DEV_HOME}
@@ -0,0 +1,35 @@
# Copyright 2017 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.
# ==============================================================================
FROM ubuntu:16.04
LABEL maintainer="Shanqing Cai <cais@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN apt-get update
RUN apt-get install -y --no-install-recommends python-pip
RUN pip install --upgrade wheel
RUN pip install --upgrade astor
RUN pip install --upgrade gast
RUN pip install --upgrade numpy
RUN pip install --upgrade termcolor
RUN pip install --upgrade keras_preprocessing
# Install golang
RUN apt-get install -t xenial-backports -y golang-1.9
ENV PATH=${PATH}:/usr/lib/go-1.9/bin
+34
View File
@@ -0,0 +1,34 @@
# Copyright 2026 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.
# ==============================================================================
FROM ubuntu:16.04
LABEL maintainer="Jan Prach <jendap@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_proto3.sh
RUN /install/install_buildifier.sh
RUN /install/install_auditwheel.sh
RUN /install/install_golang.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
@@ -0,0 +1,45 @@
# Copyright 2026 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.
# ==============================================================================
FROM ubuntu:16.04
LABEL maintainer="Rama Ketineni <rama.ketineni@intel.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
# Install gcc 7
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt update
RUN apt -y install gcc-7 g++-7
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 \
--slave /usr/bin/g++ g++ /usr/bin/g++-7
# The following line installs the Python 3.6 cross-compilation toolchain.
RUN /install/install_pi_python3x_toolchain.sh "3.6"
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
RUN python3 -V
RUN /install/install_bazel.sh
RUN /install/install_proto3.sh
RUN /install/install_buildifier.sh
RUN /install/install_auditwheel.sh
RUN /install/install_golang.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
@@ -0,0 +1,38 @@
# Copyright 2026 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.
# ==============================================================================
FROM linaro/tensorflow-arm64-build:2.17-multipython
ARG py_major_minor_version='3.10'
ENV TF_PYTHON_VERSION=${py_major_minor_version}
ENV PYTHON_BIN_PATH=/usr/bin/python${TF_PYTHON_VERSION}
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 ${PYTHON_BIN_PATH} -m pip install packaging
ARG is_nightly=0
ARG tf_project_name='tf_ci_cpu' # PyPI project name passed by CD GitHub workflow
ENV IS_NIGHTLY=${is_nightly}
ENV TF_PROJECT_NAME=${tf_project_name}
RUN ln -s /usr/lib/llvm-17/bin/clang /usr/local/bin/clang
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
@@ -0,0 +1,35 @@
# Copyright 2026 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.
# ==============================================================================
FROM ubuntu:16.04
LABEL maintainer="William Irons <wdirons@us.ibm.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN /install/install_deb_packages.sh
RUN /install/install_openblas_ppc64le.sh
RUN /install/install_hdf5_ppc64le.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel_from_source.sh
RUN /install/install_proto3.sh
RUN /install/install_buildifier_from_source.sh
RUN /install/install_auditwheel.sh
RUN /install/install_golang_ppc64le.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
@@ -0,0 +1,47 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant TensorFlow pip package with
# cuda-clang.
#
# To build, first build the manylinux2010 toolchain docker image and tag it,
# then build the TensorFlow docker image using the tagged image as base.
#
# $ docker build -f Dockerfile.rbe.cuda10.0-cudnn7-ubuntu16.04-manylinux2010 \
# --tag "local-manylinux-toolchain" .
# $ docker build -f Dockerfile.cuda-clang .
FROM local-manylinux-toolchain
WORKDIR /
RUN git clone https://github.com/tensorflow/tensorflow
WORKDIR /tensorflow
ENV TF_NEED_GCP=1 \
TF_NEED_HDFS=1 \
TF_NEED_CUDA=1 \
TF_CUDA_CLANG=1 \
PATH=/dt7/usr/bin:$PATH \
PYTHON_BIN_PATH=/usr/bin/python3.6 \
CLANG_CUDA_COMPILER_PATH=/clang_${CLANG_VERSION}/bin/clang
ADD cuda-clang.patch cuda-clang.patch
RUN patch -p1 < cuda-clang.patch
RUN yes "" | ./configure
RUN bazel build --config=opt tensorflow/tools/pip_package:build_pip_package
RUN ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tf-wheel
@@ -0,0 +1,36 @@
# Copyright 2026 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.
# ==============================================================================
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu14.04
LABEL maintainer="Yifei Feng <yifeif@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_proto3.sh
RUN /install/install_buildifier.sh
RUN /install/install_auditwheel.sh
RUN /install/install_golang.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
ENV TF_NEED_CUDA 1
@@ -0,0 +1,94 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile for Ubuntu 16.04 manylinux2010 custom ops with CPU.
FROM ubuntu:16.04 as devtoolset
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
bzip2 \
cpio \
file \
flex \
g++ \
make \
patch \
rpm2cpio \
unar \
wget \
tar \
xz-utils \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8
# TODO(klimek): Split up into two different docker images.
FROM ubuntu:16.04
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
COPY --from=devtoolset /dt7 /dt7
COPY --from=devtoolset /dt8 /dt8
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN /install/install_clang.sh
RUN /install/install_bazel.sh
RUN /install/install_buildifier.sh
# Install golang.
RUN /install/install_golang.sh
env GOROOT=/usr/local/go
env PATH=$GOROOT/bin:$PATH
# Install python 3.6.
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
python3.6 python3.6-dev python3-pip python3.6-venv && \
rm -rf /var/lib/apt/lists/* && \
python3.6 -m pip install pip --upgrade && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
# Install python 3.7
RUN /install/install_python37.sh
# Install pip3.6
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py && rm get-pip.py
RUN /install/install_pip_packages.sh
RUN /install/install_auditwheel.sh
# Make python3.6 the default python version
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
# Install given tensorflow or tf-nightly version, if not specified, install the # latest official release
ARG TF_PACKAGE=tensorflow
ARG TF_PACKAGE_VERSION=
RUN pip3 install ${TF_PACKAGE}-cpu${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}}
@@ -0,0 +1,93 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile for Ubuntu 16.04 manylinux2010 custom ops with GPU.
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04 as devtoolset
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
rpm2cpio \
unar \
wget \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8
# TODO(klimek): Split up into two different docker images.
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
COPY --from=devtoolset /dt7 /dt7
COPY --from=devtoolset /dt8 /dt8
# Install TensorRT.
RUN apt-get update && apt-get install -y \
libnvinfer-dev=5.1.5-1+cuda10.0 \
libnvinfer5=5.1.5-1+cuda10.0 \
&& \
rm -rf /var/lib/apt/lists/*
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN /install/install_clang.sh
RUN /install/install_bazel.sh
RUN /install/install_buildifier.sh
ENV TF_NEED_CUDA=1
# Install python 3.6.
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
python3.6 python3.6-dev python3-pip python3.6-venv && \
rm -rf /var/lib/apt/lists/* && \
python3.6 -m pip install pip --upgrade && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
# Install python 3.7
RUN /install/install_python37.sh
# Install pip3.6
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py && rm get-pip.py
RUN /install/install_pip_packages.sh
RUN /install/install_auditwheel.sh
# Make python3.6 the default python version
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
# Install given tensorflow or tf-nightly version, if not specified, install the # latest official release
ARG TF_PACKAGE=tensorflow
ARG TF_PACKAGE_VERSION=
RUN pip3 install ${TF_PACKAGE}${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}}
@@ -0,0 +1,95 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile for Ubuntu 16.04 manylinux2010 custom ops with GPU.
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu16.04 as devtoolset
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
rpm2cpio \
unar \
wget \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8
# TODO(klimek): Split up into two different docker images.
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu16.04
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
COPY --from=devtoolset /dt7 /dt7
COPY --from=devtoolset /dt8 /dt8
# Install TensorRT.
RUN apt-get update && apt-get install -y \
libnvinfer-dev=6.0.1-1+cuda10.1 \
libnvinfer6=6.0.1-1+cuda10.1 \
libnvinfer-plugin-dev=6.0.1-1+cuda10.1 \
libnvinfer-plugin6=6.0.1-1+cuda10.1 \
&& \
rm -rf /var/lib/apt/lists/*
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN /install/install_clang.sh
RUN /install/install_bazel.sh
RUN /install/install_buildifier.sh
ENV TF_NEED_CUDA=1
# Install python 3.6.
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
python3.6 python3.6-dev python3-pip python3.6-venv && \
rm -rf /var/lib/apt/lists/* && \
python3.6 -m pip install pip --upgrade && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
# Install python 3.7
RUN /install/install_python37.sh
# Install pip3.6
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py && rm get-pip.py
RUN /install/install_pip_packages.sh
RUN /install/install_auditwheel.sh
# Make python3.6 the default python version
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
# Install given tensorflow or tf-nightly version, if not specified, install the # latest official release
ARG TF_PACKAGE=tensorflow
ARG TF_PACKAGE_VERSION=
RUN pip3 install ${TF_PACKAGE}${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}}
@@ -0,0 +1,95 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile for Ubuntu 16.04 manylinux2010 custom ops with GPU.
FROM nvidia/cuda:11.2.1-cudnn8-devel-ubuntu16.04 as devtoolset
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
rpm2cpio \
unar \
wget \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8
# TODO(klimek): Split up into two different docker images.
FROM nvidia/cuda:11.2.1-cudnn8-devel-ubuntu16.04
LABEL maintainer="Amit Patankar <amitpatankar@google.com>"
COPY --from=devtoolset /dt7 /dt7
COPY --from=devtoolset /dt8 /dt8
# Install TensorRT.
RUN apt-get update && apt-get install -y \
libnvinfer-dev=7.2.2-1+cuda11.1 \
libnvinfer7=7.2.2-1+cuda11.1 \
libnvinfer-plugin-dev=7.2.2-1+cuda11.1 \
libnvinfer-plugin7=7.2.2-1+cuda11.1 \
&& \
rm -rf /var/lib/apt/lists/*
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN /install/install_clang.sh
RUN /install/install_bazel.sh
RUN /install/install_buildifier.sh
ENV TF_NEED_CUDA=1
# Install python 3.6.
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
python3.6 python3.6-dev python3-pip python3.6-venv && \
rm -rf /var/lib/apt/lists/* && \
python3.6 -m pip install pip --upgrade && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
# Install python 3.7
RUN /install/install_python37.sh
# Install pip3.6
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py && rm get-pip.py
RUN /install/install_pip_packages.sh
RUN /install/install_auditwheel.sh
# Make python3.6 the default python version
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
# Install given tensorflow or tf-nightly version, if not specified, install the # latest official release
ARG TF_PACKAGE=tensorflow
ARG TF_PACKAGE_VERSION=
RUN pip3 install ${TF_PACKAGE}${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}}
@@ -0,0 +1,41 @@
# Copyright 2026 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.
# ==============================================================================
FROM debian:bullseye-20221219
LABEL maintainer="Jan Prach <jendap@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" | \
tee -a /etc/apt/sources.list
# Workaround bug in Jessie backport repository deb packages
# http://serverfault.com/questions/830636/cannot-install-openjdk-8-jre-headless-on-debian-jessie
RUN apt-get update && \
apt-get install -y --no-install-recommends -t jessie-backports \
openjdk-8-jre-headless ca-certificates-java && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN /install/install_deb_packages.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_golang.sh
# Fix a virtualenv install issue specific to Debian Jessie.
RUN pip install --upgrade virtualenv
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
+54
View File
@@ -0,0 +1,54 @@
# Copyright 2026 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.
# ==============================================================================
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
LABEL maintainer="Jan Prach <jendap@google.com>"
# In the Ubuntu 16.04 images, cudnn is placed in system paths. Move them to
# /usr/local/cuda
RUN cp -P /usr/include/cudnn.h /usr/local/cuda/include
RUN cp -P /usr/lib/x86_64-linux-gnu/libcudnn* /usr/local/cuda/lib64
# Installs TensorRT, which is not included in NVIDIA Docker containers.
RUN apt-get update \
&& apt-get install nvinfer-runtime-trt-repo-ubuntu1604-5.0.2-ga-cuda10.0 \
&& apt-get update \
&& apt-get install -y --no-install-recommends libnvinfer5=5.0.2-1+cuda10.0 libnvinfer-dev=5.0.2-1+cuda10.0
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_golang.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
# Link NCCL libray and header where the build script expects them.
RUN mkdir /usr/local/cuda/lib && \
ln -s /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/lib/libnccl.so.2 && \
ln -s /usr/include/nccl.h /usr/local/cuda/include/nccl.h
# Configure the build for our CUDA configuration.
ENV TF_NEED_CUDA 1
ENV TF_NEED_TENSORRT 1
@@ -0,0 +1,45 @@
# Copyright 2026 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.
# ==============================================================================
FROM nvidia/cuda-ppc64le:9.2-cudnn7-devel-ubuntu16.04
LABEL maintainer="William Irons <wdirons@us.ibm.com>"
# In the Ubuntu 16.04 images, cudnn is placed in system paths. Move them to
# /usr/local/cuda
RUN cp -P /usr/include/cudnn.h /usr/local/cuda/include
RUN cp -P /usr/lib/powerpc64le-linux-gnu/libcudnn* /usr/local/cuda/lib64
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN /install/install_deb_packages.sh
RUN /install/install_openblas_ppc64le.sh
RUN /install/install_hdf5_ppc64le.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel_from_source.sh
RUN /install/install_golang_ppc64le.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
# Configure the build for our CUDA configuration.
ENV TF_NEED_CUDA 1
ENV TF_CUDA_COMPUTE_CAPABILITIES 3.0
ENV TF_CUDA_VERSION 9.2
ENV CUDA_TOOLKIT_PATH /usr/local/cuda-9.2
@@ -0,0 +1,47 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To build a new version, run:
# $ docker build -f Dockerfile.local-toolchain-ubuntu18.04-manylinux2010 \
# --tag "local-toolchain-ubuntu18.04-manylinux2010" .
FROM ubuntu:18.04 as local-toolchain-ubuntu18.04-manylinux2010
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
patch \
rpm2cpio \
unar \
wget \
xz-utils \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
@@ -0,0 +1,52 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2014/2014 compliant cross-compiler.
#
# Builds a devtoolset-7 environment with manylinux2014 compatible
# glibc (2.12) and libstdc++ (4.4) in /dt7.
#
# Builds a devtoolset-9 environment with manylinux2014 compatible
# glibc (2.17) and libstdc++ (4.8) in /dt9.
#
# To build a new version, run:
# $ docker build -f Dockerfile.local-toolchain-ubuntu20.04-manylinux2014 \
# --tag "local-toolchain-ubuntu20.04-manylinux2014" .
FROM ubuntu:20.04 as local-toolchain-ubuntu20.04-manylinux2014
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
patch \
rpm2cpio \
unar \
wget \
xz-utils \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.17 / libstdc++ 4.8 / devtoolset-9 in /dt9.
RUN /build_devtoolset.sh devtoolset-9 /dt9
@@ -0,0 +1,45 @@
# Copyright 2026 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.
# ==============================================================================
# Use a prebuilt Python image instead of base Ubuntu to speed up the build process,
# since it has all the build dependencies we need for Micro and downloads much faster
# than the install process.
FROM python:3.12.0a3-slim-bullseye
LABEL maintainer="Pete Warden <petewarden@google.com>"
RUN echo deb http://apt.llvm.org/buster/ llvm-toolchain-buster-12 main > /etc/apt/sources.list.d/llvm.list
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-get update
RUN apt-get install -y zip xxd sudo
RUN apt-get install -y clang-12 clang-format-12
# Set clang-12 and clang-format-12 as the default to ensure that the pigweed
# formatting scripts use the desired version.
RUN ln -s /usr/bin/clang-12 /usr/bin/clang
RUN ln -s /usr/bin/clang++-12 /usr/bin/clang++
RUN ln -s /usr/bin/clang-format-12 /usr/bin/clang-format
RUN pip install six
# Install Renode test dependencies
RUN pip install pyyaml requests psutil robotframework==3.1
# Install bazel and buildifier so that the bazel presubmit checks can be run
# from the micro docker container and are consistent with the rest of the CI.
COPY install/*.sh /install/
RUN /install/install_bazel.sh
RUN /install/install_buildifier.sh
+43
View File
@@ -0,0 +1,43 @@
# Copyright 2026 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.
# ==============================================================================
FROM ubuntu:14.04
LABEL maintainer="Jan Prach <jendap@google.com>"
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
add-apt-repository -y ppa:george-edison55/cmake-3.x
RUN /install/install_deb_packages.sh
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_proto3.sh
RUN /install/install_buildifier.sh
RUN /install/install_auditwheel.sh
RUN /install/install_golang.sh
RUN /install/install_gcc6.sh
# The following line installs the Python cross-compilation toolchain. All the
# preceding dependencies should be kept in sync with the main CPU docker file.
RUN /install/install_pi_toolchain.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
RUN chmod 644 /etc/bazel.bazelrc
# XLA is not needed for PI
ENV TF_ENABLE_XLA=0
@@ -0,0 +1,34 @@
# Copyright 2026 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.
# ==============================================================================
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cpu \
# --tag "gcr.io/tensorflow-testing/nosla-ubuntu16.04" .
# $ docker push gcr.io/tensorflow-testing/nosla-ubuntu16.04
FROM launcher.gcr.io/google/rbe-ubuntu16-04:r327695
LABEL maintainer="Yu Yi <yiyu@google.com>"
# Copy install scripts
COPY install/*.sh /install/
# Setup envvars
ENV CC /usr/local/bin/clang
ENV CXX /usr/local/bin/clang++
ENV AR /usr/bin/ar
# Run pip install script for RBE Ubuntu 16-04 container.
RUN /install/install_pip_packages_remote.sh
RUN /install/install_pip_packages.sh
@@ -0,0 +1,65 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda11.8-cudnn8.6-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda11.8-cudnn8.6-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda11.8-cudnn8.6-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:c03809a6b4008b430bf241efce78cdcd92c7bc41d11d0ba57216e97d813ac282
# Copy and run the install scripts.
ARG DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
cuda-nvml-dev-11-8 \
libnccl2=2.18.5-1+cuda11.0 \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
COPY install/install_clang_17.sh /install/
RUN /install/install_clang_17.sh
@@ -0,0 +1,59 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.1-cudnn8.9-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.1-cudnn8.9-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.1-cudnn8.9-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:3573cdabdea7f203b6440a93bb50a0e1a17c2c9a33f09fccdc0c97f514f9689c
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.2"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
@@ -0,0 +1,65 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.1-cudnn9.1-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.1-cudnn9.1-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.1-cudnn9.1-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:3573cdabdea7f203b6440a93bb50a0e1a17c2c9a33f09fccdc0c97f514f9689c
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
python3.13-nogil \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
libcudnn9-dev-cuda-12=9.1.1.17-1 \
libcudnn9-cuda-12=9.1.1.17-1 \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.2"
RUN /install/build_and_install_python.sh "3.13.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.13" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/bin/python3.13-nogil" "jax"
@@ -0,0 +1,59 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.2-cudnn8.6-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.2-cudnn8.6-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.2-cudnn8.6-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:b6f572a897a69fa3311773f949b9aa9e81bc393e4fbe2c0d56d8afb03a6de080
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
@@ -0,0 +1,61 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.2-cudnn9.1-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.2-cudnn9.1-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.2-cudnn9.1-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:7c8ecb6482e26c4b4efce0ddaefe3fb3667b3b958c83fe8d3cc3763c6ed7a4d1
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
libcudnn9-dev-cuda-12=9.1.1.17-1 \
libcudnn9-cuda-12=9.1.1.17-1 \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
@@ -0,0 +1,62 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.3-cudnn8.9-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn8.9-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn8.9-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:22d863e6fe3f98946015b9e1264b2eeb8e56e504535a6c1d5e564cae65ae5d37
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
COPY install/install_clang_18.sh /install/
RUN /install/install_clang_18.sh
@@ -0,0 +1,62 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2014 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2014 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.3-cudnn8.9-ubuntu22.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn8.9-ubuntu22.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn8.9-ubuntu22.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:dddcaf30321e9007103dce75c51b83fea3c06de462fcf41e7c6ae93f37fc3545
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.3"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
COPY install/install_clang_18.sh /install/
RUN /install/install_clang_18.sh
@@ -0,0 +1,68 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.cuda12.3-cudnn9.1-ubuntu20.04-manylinux2014-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn9.1-ubuntu20.04-manylinux2014-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-cuda12.3-cudnn9.1-ubuntu20.04-manylinux2014-multipython
FROM gcr.io/tensorflow-sigs/build@sha256:b6f572a897a69fa3311773f949b9aa9e81bc393e4fbe2c0d56d8afb03a6de080
ENV DEBIAN_FRONTEND=noninteractive
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
RUN apt-get update && apt-get install -y \
python3.13-nogil \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
patchelf \
libcudnn9-dev-cuda-12=9.1.1.17-1 \
libcudnn9-cuda-12=9.1.1.17-1 \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "3.9.18"
RUN /install/build_and_install_python.sh "3.10.13"
RUN /install/build_and_install_python.sh "3.11.6"
RUN /install/build_and_install_python.sh "3.12.0"
RUN /install/build_and_install_python.sh "3.13.0"
COPY install/install_pip_packages_by_version.sh /install/
# https://github.com/numpy/numpy/issues/22623 for `SETUPTOOLS_USE_DISTUTILS`.
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.9" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.10" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.11" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.12" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.13" "jax"
RUN SETUPTOOLS_USE_DISTUTILS=stdlib /install/install_pip_packages_by_version.sh "/usr/bin/python3.13-nogil" "jax"
COPY install/install_clang_18.sh /install/
RUN /install/install_clang_18.sh
@@ -0,0 +1,99 @@
# Copyright 2026 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.
# ==============================================================================
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To push a new version, run:
# $ docker build -f Dockerfile.rbe.ubuntu16.04-manylinux2010 \
# --tag "gcr.io/tensorflow-testing/nosla-ubuntu16.04-manylinux2010" .
# $ docker push gcr.io/tensorflow-testing/nosla-ubuntu16.04-manylinux2010
FROM ubuntu:16.04 as devtoolset
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
bzip2 \
cpio \
file \
flex \
g++ \
make \
patch \
rpm2cpio \
unar \
wget \
tar \
xz-utils \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8
# TODO(klimek): Split up into two different docker images.
FROM ubuntu:16.04
COPY --from=devtoolset /dt7 /dt7
COPY --from=devtoolset /dt8 /dt8
# Copy and run the install scripts.
COPY install/*.sh /install/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_bootstrap_deb_packages.sh
RUN /install/install_deb_packages.sh
RUN /install/install_clang.sh
RUN /install/install_bazel.sh
# Install golang.
RUN /install/install_golang.sh
env GOROOT=/usr/local/go
env PATH=$GOROOT/bin:$PATH
# Install python 3.6.
RUN yes "" | add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y \
python3.6 python3.6-dev python3-pip python3.6-venv && \
rm -rf /var/lib/apt/lists/* && \
python3.6 -m pip install pip --upgrade && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 0
RUN /install/install_pip_packages.sh
# Install python 3.8.
RUN apt-get update && apt-get install -y python3.8 python3.8-dev python3.8-venv
RUN rm -rf /var/lib/apt/lists/*
# Have to download get-pip.py due to a pip circular issue
# https://stackoverflow.com/questions/58758447/how-to-fix-module-platform-has-no-attribute-linux-distribution-when-instal
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3.8 get-pip.py
RUN python3.8 -m pip install --upgrade pip setuptools wheel
# Overwrite include paths that are generated for the multipython image.
RUN ln -sf "/usr/include/x86_64-linux-gnu/python2.7" "/dt7/usr/include/x86_64-linux-gnu/python2.7"
RUN ln -sf "/usr/include/x86_64-linux-gnu/python2.7" "/dt8/usr/include/x86_64-linux-gnu/python2.7"
RUN ln -sf "/usr/include/x86_64-linux-gnu/python3.6m" "/dt7/usr/include/x86_64-linux-gnu/python3.6m"
RUN ln -sf "/usr/include/x86_64-linux-gnu/python3.6m" "/dt8/usr/include/x86_64-linux-gnu/python3.6m"
RUN ln -sf "/usr/include/x86_64-linux-gnu/python3.8" "/dt7/usr/include/x86_64-linux-gnu/python3.8"
RUN ln -sf "/usr/include/x86_64-linux-gnu/python3.8" "/dt8/usr/include/x86_64-linux-gnu/python3.8"
+134
View File
@@ -0,0 +1,134 @@
# Copyright 2026 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.
# ==============================================================================
# This Dockerfile provides a starting point for a ROCm installation of
# MIOpen and tensorflow.
FROM ubuntu:focal
MAINTAINER Jeff Poznanovic <jeffrey.poznanovic@amd.com>
ARG ROCM_DEB_REPO=https://repo.radeon.com/rocm/apt/5.3/
ARG ROCM_BUILD_NAME=ubuntu
ARG ROCM_BUILD_NUM=main
ARG ROCM_PATH=/opt/rocm-5.3.0
ENV DEBIAN_FRONTEND noninteractive
ENV TF_NEED_ROCM 1
ENV HOME /root/
RUN apt-get --allow-unauthenticated update && apt install -y wget software-properties-common
# Add rocm repository
RUN apt-get clean all
RUN wget -qO - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -;
RUN bin/bash -c 'if [[ $ROCM_DEB_REPO == https://repo.radeon.com/rocm/* ]] ; then \
echo "deb [arch=amd64] $ROCM_DEB_REPO $ROCM_BUILD_NAME $ROCM_BUILD_NUM" > /etc/apt/sources.list.d/rocm.list; \
else \
echo "deb [arch=amd64 trusted=yes] $ROCM_DEB_REPO $ROCM_BUILD_NAME $ROCM_BUILD_NUM" > /etc/apt/sources.list.d/rocm.list ; \
fi'
# Install misc pkgs
RUN apt-get update --allow-insecure-repositories && DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
bsdmainutils \
clang-6.0 \
clang-format-6.0 \
clang-tidy-6.0 \
cmake \
cmake-qt-gui \
ssh \
curl \
apt-utils \
pkg-config \
g++-multilib \
git \
kmod \
libunwind-dev \
libfftw3-dev \
libelf-dev \
libncurses5-dev \
libpthread-stubs0-dev \
vim \
gfortran \
libboost-program-options-dev \
libssl-dev \
libboost-dev \
libboost-system-dev \
libboost-filesystem-dev \
rpm \
libnuma-dev \
patchelf \
pciutils \
virtualenv \
python3-pip \
libxml2 \
libxml2-dev \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Add to get ppa
RUN apt-get update
RUN apt-get install -y software-properties-common
# Install rocm pkgs
RUN apt-get update --allow-insecure-repositories && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
rocm-dev rocm-libs rccl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set up paths
ENV HCC_HOME=$ROCM_PATH/hcc
ENV HIP_PATH=$ROCM_PATH/hip
ENV OPENCL_ROOT=$ROCM_PATH/opencl
ENV PATH="$HCC_HOME/bin:$HIP_PATH/bin:${PATH}"
ENV PATH="$ROCM_PATH/bin:${PATH}"
ENV PATH="$OPENCL_ROOT/bin:${PATH}"
ENV PATH="/usr/local/bin:${PATH}"
# Add target file to help determine which device(s) to build for
RUN bash -c 'echo -e "gfx900\ngfx906\ngfx908" >> ${ROCM_PATH}/bin/target.lst'
# Need to explicitly create the $ROCM_PATH/.info/version file to workaround what seems to be a bazel bug
# The env vars being set via --action_env in .bazelrc and .tf_configure.bazelrc files are sometimes
# not getting set in the build command being spawned by bazel (in theory this should not happen)
# As a consequence ROCM_PATH is sometimes not set for the hipcc commands.
# When hipcc incokes hcc, it specifies $ROCM_PATH/.../include dirs via the `-isystem` options
# If ROCM_PATH is not set, it defaults to /opt/rocm, and as a consequence a dependency is generated on the
# header files included within `/opt/rocm`, which then leads to bazel dependency errors
# Explicitly creating the $ROCM_PATH/.info/version allows ROCM path to be set correrctly, even when ROCM_PATH
# is not explicitly set, and thus avoids the eventual bazel dependency error.
# The bazel bug needs to be root-caused and addressed, but that is out of our control and may take a long time
# to come to fruition, so implementing the workaround to make do till then
# Filed https://github.com/bazelbuild/bazel/issues/11163 for tracking this
RUN touch ${ROCM_PATH}/.info/version
ENV PATH="/root//bin:/root/.local/bin:$PATH"
# Copy and run the install scripts.
COPY install/*.sh /install/
COPY release/common.sh /install/common.sh
COPY release/* tensorflow/tools/ci_build/release/
ARG DEBIAN_FRONTEND=noninteractive
RUN /install/install_deb_packages.sh
SHELL ["/bin/bash", "-c"]
RUN /install/install_bazel.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
# Configure the build for our ROCm configuration.
ENV TF_NEED_ROCM 1
# This is a temporary workaround to fix Out-Of-Memory errors we are running into with XLA perf tests
# By default, HIP runtime "hides" 256MB from the TF Runtime, but with recent changes (update to ROCm2.3, dynamic loading of roc* libs, et al)
# it seems that we need to up the threshold slightly to 320MB
ENV HIP_HIDDEN_FREE_MEM=320
+111
View File
@@ -0,0 +1,111 @@
# TensorFlow Builds
This directory contains all the files and setup instructions to run all the
important builds and tests. You can run it yourself!
## Run It Yourself
You have two options when running TensorFlow tests locally on your
machine. First, using docker, you can run our Continuous Integration
(CI) scripts on tensorflow devel images. The other option is to install
all TensorFlow dependencies on your machine and run the scripts
natively on your system.
### Run TensorFlow CI Scripts using Docker
1. Install Docker following the [instructions on the docker website](https://docs.docker.com/engine/installation/).
2. Start a container with one of the devel images here:
https://hub.docker.com/r/tensorflow/tensorflow/tags/.
3. Based on your choice of the image, pick one of the scripts under
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/ci_build/linux
and run them from the TensorFlow repository root.
### Run TensorFlow CI Scripts Natively on your Machine
1. Follow the instructions at https://www.tensorflow.org/install/source,
but stop when you get to the section "Configure the installation". You do not
need to configure the installation to run the CI scripts.
2. Pick the appropriate OS and python version you have installed,
and run the script under tensorflow/tools/ci_build/<OS>.
## TensorFlow Continuous Integration
To verify that new changes dont break TensorFlow, we run builds and
tests on either [Jenkins](https://jenkins-ci.org/) or a CI system
internal to Google.
We can trigger builds and tests on updates to master or on each pull
request. Contact one of the repository maintainers to trigger builds
on your pull request.
### View CI Results
The Pull Request will show if the change passed or failed the checks.
From the pull request, click **Show all checks** to see the list of builds
and tests. Click on **Details** to see the results from Jenkins or the internal
CI system.
Results from Jenkins are displayed in the Jenkins UI. For more information,
see the [Jenkins documentation](https://jenkins.io/doc/).
Results from the internal CI system are displayed in the Build Status UI. In
this UI, to see the logs for a failed build:
* Click on the **INVOCATION LOG** tab to see the invocation log.
* Click on the **ARTIFACTS** tab to see a list of all artifacts, including logs.
* Individual test logs may be available. To see these logs, from the **TARGETS**
tab, click on the failed target. Then, click on the **TARGET LOG** tab to see
its test log.
If youre looking at target that is sharded or a test that is flaky, then
the build tool divided the target into multiple shards or ran the test
multiple times. Each test log is specific to the shard, run, and attempt.
To see a specific log:
1. Click on the log icon that is on the right next to the shard, run,
and attempt number.
2. In the grid that appears on the right, click on the specific shard,
run, and attempt to view its log. You can also type the desired shard,
run, or attempt number in the field above its grid.
### Third party TensorFlow CI
#### [Mellanox](https://www.mellanox.com/) TensorFlow CI
##### How to start CI
* Submit special pull request (PR) comment to trigger CI: **bot:mlx:test**
* Test session is run automatically.
* Test results and artifacts (log files) are reported via PR comments
##### CI Steps
CI includes the following steps: * Build TensorFlow (GPU version) * Run
TensorFlow tests: *
[TF CNN benchmarks](https://github.com/tensorflow/benchmarks/blob/master/scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py)
(TensorFlow 1.13 and less) *
[TF models](https://github.com/tensorflow/models/tree/master/official/r1/resnet)
(TensorFlow 2.0): ResNet, synthetic data, NCCL, multi_worker_mirrored
distributed strategy
##### Test Environment
CI is run in the Mellanox lab on a 2-node cluster with the following parameters:
* Hardware * IB: 1x ConnectX-6 HCA (connected to Mellanox Quantum™ HDR switch) *
GPU: 1x Nvidia Tesla K40m * Software * Ubuntu 16.04.6 * Internal stable
[MLNX_OFED](https://www.mellanox.com/page/products_dyn?product_family=26),
[HPC-X™](https://www.mellanox.com/page/hpcx_overview) and
[SHARP™](https://www.mellanox.com/page/products_dyn?product_family=261&mtag=sharp)
versions
##### Support (Mellanox)
With any questions/suggestions or in case of issues contact
[Artem Ryabov](mailto:artemry@mellanox.com).
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Copyright 2020 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
docker pull tensorflow/tensorflow:devel-gpu
docker run --gpus all -w /tensorflow_src -v $PWD:/mnt -e HOST_PERMS="$(id -u):$(id -g)" \
tensorflow/tensorflow:devel-gpu bash -c "git pull; bazel test --config=cuda -c opt --test_tag_filters=gpu,-no_gpu,-benchmark-test,-no_oss,-oss_excluded,-oss_serial,-v1only,-no_gpu_presubmit,-no_cuda11 -- //tensorflow/... -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/compiler/mlir/tosa/... //tensorflow/compiler/mlir/lite/... -//tensorflow/lite/micro/examples/... -//tensorflow/core/tpu/... -//tensorflow/lite/..."
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
# Copyright 2020 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.
# ==============================================================================
# Script for helping to record method for building the RBE docker images.
#
# The first argument to the script is expected to be the name of the docker file
# to build. Example:
#
# $ ./build_rbe.sh Dockerfile.rbe.ubuntu16.04-manylinux2010
function main() {
set -eu
cd "${0%/*}"
local DOCKERFILE="$(basename "$1")"
if [[ ! -e "$DOCKERFILE" ]]; then
echo "$DOCKERFILE does not exist in $PWD" >> /dev/stderr
exit 1
fi
local IMAGE_NAME_SUFFIX="${1#Dockerfile.rbe.}"
if [[ "$IMAGE_NAME_SUFFIX" == "$DOCKERFILE" ]]; then
echo 'File must start with "Dockerfile.rbe."' >> /dev/stderr
exit 1
fi
local ARGS=(
--config=cloudbuild.yaml
--machine-type=n1-highcpu-32
--substitutions=_DOCKERFILE="$1",_IMAGE_NAME="nosla-$IMAGE_NAME_SUFFIX"
--timeout=1h
)
gcloud --project=tensorflow-testing builds submit "${ARGS[@]}" .
}
main "$@"
@@ -0,0 +1,19 @@
# Copyright 2019 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.
# ==============================================================================
#!/bin/bash
set -x
ARM_SKIP_TESTS="-//tensorflow/lite/... \
"
@@ -0,0 +1,21 @@
# Copyright 2019 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.
# ==============================================================================
#!/bin/bash
set -x
source tensorflow/tools/ci_build/build_scripts/ARM_SKIP_TESTS.sh
ARM_SKIP_TESTS="${ARM_SKIP_TESTS} \
"
@@ -0,0 +1,23 @@
# Copyright 2019 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.
# ==============================================================================
#!/bin/bash
set -x
DEFAULT_BAZEL_TARGETS="//tensorflow/... \
-//tensorflow/compiler/tf2tensorrt/... \
-//tensorflow/core/tpu/... \
-//tensorflow/go/... \
-//tensorflow/java/... \
-//tensorflow/tools/toolchains/..."
@@ -0,0 +1,4 @@
# Default targets run by presubmits.
This bash script is invoked internally to run presubmits. Please only modify
default bazel targets.
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Copyright 2015 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
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds_common.sh"
# To setup Android via `configure` script.
export TF_SET_ANDROID_WORKSPACE=1
yes "" | ./configure
# The Bazel builds are intentionally built for x86 and arm64 to maximize build
# coverage while minimizing compilation time. For full build coverage and
# exposed binaries, see android_full.sh
echo "========== TensorFlow Basic Build Test =========="
TARGETS=
# Building the Eager Runtime ensures compatibility with Android for the
# benefits of clients like TensorFlow Lite. For now it is enough to build only
# :execute, which what TF Lite needs. Note that this does *not* build the
# full set of mobile ops/kernels, as that can be prohibitively expensive.
TARGETS+=" //tensorflow/core/common_runtime/eager:execute"
bazel --bazelrc=/dev/null build \
--compilation_mode=opt --cxxopt=-std=c++17 \
--config=android_arm64 --fat_apk_cpu=x86,arm64-v8a \
${TARGETS}
# TODO(b/122377443): Restore Makefile builds after resolving r18b build issues.
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# Copyright 2015 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
copy_lib() {
FILE=$1
TARGET_DIR=${OUT_DIR}/native/$(basename $FILE)/${CPU}
mkdir -p ${TARGET_DIR}
echo "Copying ${FILE} to ${TARGET_DIR}"
cp ${FILE} ${TARGET_DIR}
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds_common.sh"
# To setup Android via `configure` script.
export TF_SET_ANDROID_WORKSPACE=1
yes "" | ./configure
CPUS=armeabi-v7a,arm64-v8a
OUT_DIR="$(pwd)/out/"
AAR_LIB_TMP="$(pwd)/aar_libs"
rm -rf ${OUT_DIR}
rm -rf ${AAR_LIB_TMP}
# Build all relevant native libraries for each architecture.
for CPU in ${CPUS//,/ }
do
echo "========== Building native libs for Android ${CPU} =========="
bazel build --config=monolithic --cpu=${CPU} \
--compilation_mode=opt --cxxopt=-std=c++17 \
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
//tensorflow/core:portable_tensorflow_lib \
//tensorflow/tools/android/inference_interface:libtensorflow_inference.so \
//tensorflow/tools/android/test:libtensorflow_demo.so \
//tensorflow/tools/benchmark:benchmark_model
copy_lib bazel-bin/tensorflow/tools/android/inference_interface/libtensorflow_inference.so
copy_lib bazel-bin/tensorflow/tools/android/test/libtensorflow_demo.so
copy_lib bazel-bin/tensorflow/tools/benchmark/benchmark_model
mkdir -p ${AAR_LIB_TMP}/jni/${CPU}
cp bazel-bin/tensorflow/tools/android/inference_interface/libtensorflow_inference.so ${AAR_LIB_TMP}/jni/${CPU}
done
# Build Jar and also demo containing native libs for all architectures.
# Enable sandboxing so that zip archives don't get incorrectly packaged
# in assets/ dir (see https://github.com/bazelbuild/bazel/issues/2334)
# TODO(gunan): remove extra flags once sandboxing is enabled for all builds.
echo "========== Building TensorFlow Android Jar and Demo =========="
bazel --bazelrc=/dev/null build --config=monolithic --fat_apk_cpu=${CPUS} \
--compilation_mode=opt --cxxopt=-std=c++17 \
--define=android_dexmerger_tool=d8_dexmerger \
--define=android_incremental_dexing_tool=d8_dexbuilder \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--spawn_strategy=sandboxed --genrule_strategy=sandboxed \
//tensorflow/tools/android/inference_interface:android_tensorflow_inference_java \
//tensorflow/tools/android/inference_interface:android_tensorflow_inference_java.aar \
//tensorflow/tools/android/test:tensorflow_demo
echo "Copying demo, AAR and Jar to ${OUT_DIR}"
cp bazel-bin/tensorflow/tools/android/test/tensorflow_demo.apk \
bazel-bin/tensorflow/tools/android/inference_interface/libandroid_tensorflow_inference_java.jar ${OUT_DIR}
cp bazel-bin/tensorflow/tools/android/inference_interface/android_tensorflow_inference_java.aar \
${OUT_DIR}/tensorflow.aar
# TODO(andrewharp): build native libs into AAR directly once
# https://github.com/bazelbuild/bazel/issues/348 is resolved.
echo "Adding native libs to AAR"
chmod +w ${OUT_DIR}/tensorflow.aar
pushd ${AAR_LIB_TMP}
zip -ur ${OUT_DIR}/tensorflow.aar $(find jni -name *.so)
popd
rm -rf ${AAR_LIB_TMP}
# TODO(b/122377443): Restore Makefile builds after resolving r18b build issues.
+155
View File
@@ -0,0 +1,155 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
# Runs benchmark tests.
# After the completion of each benchmark test, the script calls a hook binary,
# specified with the environment variable TF_BUILD_BENCHMARK_HOOK, to handle
# the test log file. This hook binary may perform operations such as entering
# the test results into a database.
#
# Usage: benchmark [-c opt]
# Option flags
# -c opt: Use optimized C++ build ("-c opt")
#
# This script obeys the following environmental variables:
# TF_BUILD_BENCHMARK_HOOK:
# Path to a binary / script that will handle the test log and other related
# info after the completion of each benchmark test.
set -u
echo ""
echo "====== Benchmark tests start ======"
# Process input arguments
OPT_FLAG=""
while getopts c: flag; do
case ${flag} in
c)
if [[ ! -z "{OPTARG}" ]]; then
OPT_FLAG="${OPT_FLAG} -c ${OPTARG}"
fi
;;
esac
done
BENCHMARK_HOOK=${TF_BUILD_BENCHMARK_HOOK:-""}
BENCHMARK_TAG="benchmark-test"
BENCHMARK_TESTS=$(bazel query \
'attr("tags", "'"${BENCHMARK_TAG}"'", //tensorflow/...)')
if [[ -z "${BENCHMARK_TESTS}" ]]; then
echo "ERROR: Cannot find any benchmark tests with the tag "\
"\"${BENCHMARK_TAG}\""
exit 1
fi
N_TESTS=$(echo ${BENCHMARK_TESTS} | wc -w)
echo "Discovered ${N_TESTS} benchmark test(s) with the tag \"${BENCHMARK_TAG}\":"
echo ${BENCHMARK_TESTS}
echo ""
PASS_COUNTER=0
FAIL_COUNTER=0
FAILED_TESTS=""
COUNTER=0
# Iterate through the benchmark tests
for BENCHMARK_TEST in ${BENCHMARK_TESTS}; do
((COUNTER++))
echo ""
echo "Running benchmark test (${COUNTER} / ${N_TESTS}): ${BENCHMARK_TEST}"
bazel test ${OPT_FLAG} --cache_test_results=no "${BENCHMARK_TEST}"
TEST_RESULT=$?
# Hook for database
# Verify that test log exists
TEST_LOG=$(echo ${BENCHMARK_TEST} | sed -e 's/:/\//g')
TEST_LOG="bazel-testlogs/${TEST_LOG}/test.log"
if [[ -f "${TEST_LOG}" ]]; then
echo "Benchmark ${BENCHMARK_TEST} done: log @ ${TEST_LOG}"
# Call database hook if exists
if [[ ! -z "${BENCHMARK_HOOK}" ]]; then
# Assume that the hook binary/script takes two arguments:
# Argument 1: Compilation flags such as "-c opt" as a whole
# Argument 2: Test log containing the serialized TestResults proto
echo "Calling database hook: ${TF_BUILD_BENCHMARK_LOG_HOOK} "\
"${OPT_FLAG} ${TEST_LOG}"
${TF_BUILD_BENCHMARK_LOG_HOOK} "${OPT_FLAG}" "${TEST_LOG}"
else
echo "WARNING: No hook binary is specified to handle test log ${TEST_LOG}"
fi
else
# Mark as failure if the test log file cannot be found
TEST_RESULT=2
echo "ERROR: Cannot find log file from benchmark ${BENCHMARK_TEST} @ "\
"${TEST_LOG}"
fi
echo ""
if [[ ${TEST_RESULT} -eq 0 ]]; then
((PASS_COUNTER++))
echo "Benchmark test PASSED: ${BENCHMARK_TEST}"
else
((FAIL_COUNTER++))
FAILED_TESTS="${FAILED_TESTS} ${BENCHMARK_TEST}"
echo "Benchmark test FAILED: ${BENCHMARK_TEST}"
if [[ -f "${TEST_LOG}" ]]; then
echo "============== BEGINS failure log content =============="
cat ${TEST_LOG} >&2
echo "============== ENDS failure log content =============="
echo ""
fi
fi
done
# Summarize test results
echo ""
echo "${N_TESTS} Benchmark test(s):" \
"${PASS_COUNTER} passed;" \
"${FAIL_COUNTER} failed"
if [[ ${FAIL_COUNTER} -eq 0 ]]; then
echo ""
echo "Benchmark tests SUCCEEDED"
exit 0
else
echo "FAILED benchmark test(s):"
FAIL_COUNTER=0
for TEST_NAME in ${FAILED_TESTS}; do
echo " ${TEST_NAME}"
((FAIL_COUNTER++))
done
echo ""
echo "Benchmark tests FAILED"
exit 1
fi
@@ -0,0 +1,242 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
# Common Bash functions used by build scripts
COLOR_NC='\033[0m'
COLOR_BOLD='\033[1m'
COLOR_LIGHT_GRAY='\033[0;37m'
COLOR_GREEN='\033[0;32m'
COLOR_RED='\033[0;31m'
die() {
# Print a message and exit with code 1.
#
# Usage: die <error_message>
# e.g., die "Something bad happened."
echo $@
exit 1
}
realpath() {
# Get the real path of a file
# Usage: realpath <file_path>
if [[ $# != "1" ]]; then
die "realpath: incorrect usage"
fi
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
to_lower () {
# Convert string to lower case.
# Usage: to_lower <string>
echo "$1" | tr '[:upper:]' '[:lower:]'
}
calc_elapsed_time() {
# Calculate elapsed time. Takes nanosecond format input of the kind output
# by date +'%s%N'
#
# Usage: calc_elapsed_time <START_TIME> <END_TIME>
if [[ $# != "2" ]]; then
die "calc_elapsed_time: incorrect usage"
fi
START_TIME=$1
END_TIME=$2
if [[ ${START_TIME} == *"N" ]]; then
# Nanosecond precision not available
START_TIME=$(echo ${START_TIME} | sed -e 's/N//g')
END_TIME=$(echo ${END_TIME} | sed -e 's/N//g')
ELAPSED="$(expr ${END_TIME} - ${START_TIME}) s"
else
ELAPSED="$(expr $(expr ${END_TIME} - ${START_TIME}) / 1000000) ms"
fi
echo ${ELAPSED}
}
run_in_directory() {
# Copy the test script to a destination directory and run the test there.
# Write test log to a log file.
#
# Usage: run_in_directory <DEST_DIR> <LOG_FILE> <TEST_SCRIPT>
# [ARGS_FOR_TEST_SCRIPT]
if [[ $# -lt "3" ]]; then
die "run_in_directory: incorrect usage"
fi
DEST_DIR="$1"
LOG_FILE="$2"
TEST_SCRIPT="$3"
shift 3
SCRIPT_ARGS=("$@")
# Get the absolute path of the log file
LOG_FILE_ABS=$(realpath "${LOG_FILE}")
cp "${TEST_SCRIPT}" "${DEST_DIR}"/
SCRIPT_BASENAME=$(basename "${TEST_SCRIPT}")
if [[ ! -f "${DEST_DIR}/${SCRIPT_BASENAME}" ]]; then
echo "FAILED to copy script ${TEST_SCRIPT} to temporary directory "\
"${DEST_DIR}"
return 1
fi
pushd "${DEST_DIR}" > /dev/null
"${TIMEOUT_BIN}" --preserve-status ${TIMEOUT} \
"${PYTHON_BIN_PATH}" "${SCRIPT_BASENAME}" ${SCRIPT_ARGS[@]} 2>&1 \
> "${LOG_FILE_ABS}"
rm -f "${SCRIPT_BASENAME}"
popd > /dev/null
if [[ $? != 0 ]]; then
echo "Test \"${SCRIPT_BASENAME}\" FAILED"
return 1
fi
return 0
}
test_runner() {
# Run a suite of tests, print failure logs (if any), wall-time each test,
# and show the summary at the end.
#
# Usage: test_runner <TEST_DESC> <ALL_TESTS> <TEST_DENYLIST> <LOGS_DIR>
# e.g., test_runner "Tutorial test-on-install" \
# "test1 test2 test3" "test2 test3" "/tmp/log_dir"
if [[ $# != "4" ]]; then
die "test_runner: incorrect usage"
fi
TEST_DESC=$1
ALL_TESTS_STR=$2
TEST_DENYLIST_SR=$3
LOGS_DIR=$4
NUM_TESTS=$(echo "${ALL_TESTS_STR}" | wc -w)
ALL_TESTS=(${ALL_TESTS_STR})
COUNTER=0
PASSED_COUNTER=0
FAILED_COUNTER=0
FAILED_TESTS=""
FAILED_TEST_LOGS=""
SKIPPED_COUNTER=0
for CURR_TEST in ${ALL_TESTS[@]}; do
((COUNTER++))
STAT_STR="(${COUNTER} / ${NUM_TESTS})"
if [[ "${TEST_DENYLIST_STR}" == *"${CURR_TEST}"* ]]; then
((SKIPPED_COUNTER++))
echo "${STAT_STR} Denylisted ${TEST_DESC} SKIPPED: ${CURR_TEST}"
continue
fi
START_TIME=$(date +'%s%N')
LOG_FILE="${LOGS_DIR}/${CURR_TEST}.log"
rm -rf ${LOG_FILE} ||
die "Unable to remove existing log file: ${LOG_FILE}"
"test_${CURR_TEST}" "${LOG_FILE}"
TEST_RESULT=$?
END_TIME=$(date +'%s%N')
ELAPSED_TIME=$(calc_elapsed_time "${START_TIME}" "${END_TIME}")
if [[ ${TEST_RESULT} == 0 ]]; then
((PASSED_COUNTER++))
echo "${STAT_STR} ${TEST_DESC} PASSED: ${CURR_TEST} "\
"(Elapsed time: ${ELAPSED_TIME})"
else
((FAILED_COUNTER++))
FAILED_TESTS="${FAILED_TESTS} ${CURR_TEST}"
FAILED_TEST_LOGS="${FAILED_TEST_LOGS} ${LOG_FILE}"
echo "${STAT_STR} ${TEST_DESC} FAILED: ${CURR_TEST} "\
"(Elapsed time: ${ELAPSED_TIME})"
echo "============== BEGINS failure log content =============="
cat ${LOG_FILE}
echo "============== ENDS failure log content =============="
echo ""
fi
done
echo "${NUM_TUT_TESTS} ${TEST_DESC} test(s): "\
"${PASSED_COUNTER} passed; ${FAILED_COUNTER} failed; ${SKIPPED_COUNTER} skipped"
if [[ ${FAILED_COUNTER} -eq 0 ]]; then
echo ""
echo "${TEST_DESC} SUCCEEDED"
exit 0
else
echo "FAILED test(s):"
FAILED_TEST_LOGS=($FAILED_TEST_LOGS)
FAIL_COUNTER=0
for TEST_NAME in ${FAILED_TESTS}; do
echo " ${TEST_DESC} (Log @: ${FAILED_TEST_LOGS[${FAIL_COUNTER}]})"
((FAIL_COUNTER++))
done
echo ""
die "${TEST_DESC} FAILED"
fi
}
configure_android_workspace() {
# Modify the WORKSPACE file.
# Note: This is workaround. This should be done by bazel.
if grep -q '^android_sdk_repository' WORKSPACE && grep -q '^android_ndk_repository' WORKSPACE; then
echo "You probably have your WORKSPACE file setup for Android."
else
if [ -z "${ANDROID_API_LEVEL}" -o -z "${ANDROID_BUILD_TOOLS_VERSION}" ] || \
[ -z "${ANDROID_SDK_HOME}" -o -z "${ANDROID_NDK_HOME}" ]; then
echo "ERROR: Your WORKSPACE file does not seems to have proper android"
echo " configuration and not all the environment variables expected"
echo " inside ci_build android docker container are set."
echo " Please configure it manually. See: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/android/test/README.md"
else
cat << EOF >> WORKSPACE
android_sdk_repository(
name = "androidsdk",
api_level = ${ANDROID_API_LEVEL},
build_tools_version = "${ANDROID_BUILD_TOOLS_VERSION}",
path = "${ANDROID_SDK_HOME}",
)
android_ndk_repository(
name="androidndk",
path="${ANDROID_NDK_HOME}",
api_level=21)
EOF
fi
fi
}
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env python
# Copyright 2020 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.
# ==============================================================================
#
# Checks that the options mentioned in syslibs_configure.bzl are consistent with
# the valid options in workspace.bzl
# Expects the tensorflow source folder as the first argument
import glob
import os
import sys
tf_source_path = sys.argv[1]
syslibs_configure_path = os.path.join(tf_source_path, 'third_party',
'systemlibs', 'syslibs_configure.bzl')
workspace0_path = os.path.join(tf_source_path, 'tensorflow', 'workspace0.bzl')
workspace_glob = os.path.join(tf_source_path, 'tensorflow', 'workspace*.bzl')
third_party_path = os.path.join(tf_source_path, 'third_party')
third_party_glob = os.path.join(third_party_path, '*', 'workspace.bzl')
if not os.path.isdir(tf_source_path):
raise ValueError('The path to the TensorFlow source must be passed as'
' the first argument')
if not os.path.isfile(syslibs_configure_path):
raise ValueError('Could not find syslibs_configure.bzl at %s' %
syslibs_configure_path)
if not os.path.isfile(workspace0_path):
raise ValueError('Could not find workspace0.bzl at %s' % workspace0_path)
def extract_valid_libs(filepath):
"""Evaluate syslibs_configure.bzl, return the VALID_LIBS set from that file."""
# Stub only
def repository_rule(**kwargs): # pylint: disable=unused-variable
del kwargs
# Populates VALID_LIBS
with open(filepath, 'r') as f:
f_globals = {'repository_rule': repository_rule}
f_locals = {}
exec(f.read(), f_globals, f_locals) # pylint: disable=exec-used
return set(f_locals['VALID_LIBS'])
def extract_system_builds(filepath):
"""Extract the 'name' argument of all rules with a system_build_file argument."""
lib_names = []
system_build_files = []
current_name = None
with open(filepath, 'r') as f:
for line in f:
line = line.strip()
if line.startswith('name = '):
current_name = line[7:-1].strip('"')
elif line.startswith('system_build_file = '):
lib_names.append(current_name)
# Split at '=' to extract rhs, then extract value between quotes
system_build_spec = line.split('=')[-1].split('"')[1]
assert system_build_spec.startswith('//')
system_build_files.append(system_build_spec[2:].replace(':', os.sep))
return lib_names, system_build_files
syslibs = extract_valid_libs(syslibs_configure_path)
syslibs_from_workspace = set()
system_build_files_from_workspace = []
for current_path in glob.glob(workspace_glob) + glob.glob(third_party_glob):
cur_lib_names, build_files = extract_system_builds(current_path)
syslibs_from_workspace.update(cur_lib_names)
system_build_files_from_workspace.extend(build_files)
missing_build_files = [
file for file in system_build_files_from_workspace
if not os.path.isfile(os.path.join(tf_source_path, file))
]
has_error = False
if missing_build_files:
has_error = True
print('Missing system build files: ' + ', '.join(missing_build_files))
if syslibs != syslibs_from_workspace:
has_error = True
# Libs present in workspace files but not in the allowlist
missing_syslibs = syslibs_from_workspace - syslibs
if missing_syslibs:
libs = ', '.join(sorted(missing_syslibs))
print('Libs missing from syslibs_configure: ' + libs)
# Libs present in the allow list but not in workspace files
additional_syslibs = syslibs - syslibs_from_workspace
if additional_syslibs:
libs = ', '.join(sorted(additional_syslibs))
print('Libs missing in workspace (or superfluous in syslibs_configure): ' +
libs)
sys.exit(1 if has_error else 0)
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Copyright 2016 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
# Determine the number of cores, for parallel make.
N_JOBS=$(grep -c ^processor /proc/cpuinfo)
if [[ -z ${N_JOBS} ]]; then
# The Linux way didn't work. Try the Mac way.
N_JOBS=$(sysctl -n hw.ncpu)
fi
if [[ -z ${N_JOBS} ]]; then
N_JOBS=1
echo ""
echo "WARNING: Failed to determine the number of CPU cores. "\
"Will use --jobs=1 for make."
fi
echo ""
echo "make will use ${N_JOBS} concurrent job(s)."
echo ""
# Run TensorFlow cmake build.
# Clean up, because certain modules, e.g., highwayhash, seem to be sensitive
# to state.
rm -rf build
mkdir -p build
pushd build
cmake -DCMAKE_BUILD_TYPE=Release ../tensorflow/contrib/cmake
make --jobs=${N_JOBS} all
popd
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# ==============================================================================
# This script is a wrapper to run any build inside the docker container
# when running ci_build.sh. It's purpose is to automate the call of ./configure.
# Yes, this script is a workaround of a workaround.
#
# Usage: configured <CONTAINER_TYPE> [--disable-gcp] <COMMAND>
#
# The optional flag --disable-gcp disabled support for Google Cloud Platform
# (GCP) in the builds.
set -e
CONTAINER_TYPE=$( echo "$1" | tr '[:upper:]' '[:lower:]' )
shift 1
COMMAND=("$@")
export CI_BUILD_PYTHON="${CI_BUILD_PYTHON:-python}"
export PYTHON_BIN_PATH="${PYTHON_BIN_PATH:-$(which ${CI_BUILD_PYTHON})}"
# XLA currently does not build under Android, so disable it for now.
if [[ "${CONTAINER_TYPE}" == 'android' ]]; then
export TF_ENABLE_XLA=0
fi
if [[ "${CONTAINER_TYPE}" == 'rocm' ]]; then
export TF_NEED_CLANG=0
fi
pushd "${CI_TENSORFLOW_SUBMODULE_PATH:-.}"
yes "" | $PYTHON_BIN_PATH configure.py
popd
# Gather and print build information
SCRIPT_DIR=$( cd ${0%/*} && pwd -P )
${SCRIPT_DIR}/print_build_info.sh ${CONTAINER_TYPE} ${COMMAND[@]}
${COMMAND[@]}
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
# Copyright 2016 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 -x
cd bazel_pip
virtualenv --system-site-packages --python=python .env
source .env/bin/activate
pip --version
pip install portpicker
pip install *.whl
# Install bazelisk
rm -rf ~/bin/bazel
mkdir ~/bin/bazel
wget --no-verbose -O "~/bin/bazel" \
"https://github.com/bazelbuild/bazelisk/releases/download/v1.3.0/bazelisk-linux-amd64"
chmod u+x "~/bin/bazel"
if [[ ! ":$PATH:" =~ :"~"/bin/?: ]]; then
PATH="~/bin:$PATH"
fi
which bazel
bazel version
# Use default configuration
yes "" | python configure.py
PIP_TEST_ROOT=pip_test_root
mkdir -p ${PIP_TEST_ROOT}
ln -s $(pwd)/tensorflow ${PIP_TEST_ROOT}/tensorflow
bazel --output_base=/tmp test --define=no_tensorflow_py_deps=true \
--test_lang_filters=py \
--build_tests_only \
-k \
--test_tag_filters=-no_oss,-oss_excluded,-oss_serial,-no_pip,-nopip,-gpu,-tpu \
--test_size_filters=small,medium \
--test_timeout 300,450,1200,3600 \
--test_output=errors \
-- //${PIP_TEST_ROOT}/tensorflow/python/... \
-//${PIP_TEST_ROOT}/tensorflow/python/compiler/xla:xla_test \
-//${PIP_TEST_ROOT}/tensorflow/python/distribute:parameter_server_strategy_test \
-//${PIP_TEST_ROOT}/tensorflow/python/client:virtual_gpu_test \
-//${PIP_TEST_ROOT}/tensorflow/python:collective_ops_gpu_test
# The above tests are excluded because they seem to require a GPU.
# TODO(yifeif): Investigate and potentially add an unconditional 'gpu' tag.
+134
View File
@@ -0,0 +1,134 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
# Build and test TensorFlow docker images.
# The tests include Python unit tests-on-install and tutorial tests.
#
# Usage: docker_test.sh <IMAGE_TYPE> <TAG> <WHL_PATH>
# Arguments:
# IMAGE_TYPE : Type of the image: (CPU|GPU|ROCM)
# TAG : Docker image tag
# WHL_PATH : Path to the whl file to be installed inside the docker image
#
# e.g.: docker_test.sh CPU someone/tensorflow:0.8.0 pip_test/whl/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
#
# Helper functions
# Exit after a failure
die() {
echo $@
exit 1
}
# Convert to lower case
to_lower () {
echo "$1" | tr '[:upper:]' '[:lower:]'
}
# Helper function to traverse directories up until given file is found.
function upsearch () {
test / == "$PWD" && return || \
test -e "$1" && echo "$PWD" && return || \
cd .. && upsearch "$1"
}
# Verify command line argument
if [[ $# != "3" ]]; then
die "Usage: $(basename $0) <IMAGE_TYPE> <TAG> <WHL_PATH>"
fi
IMAGE_TYPE=$(to_lower "$1")
DOCKER_IMG_TAG=$2
WHL_PATH=$3
# Verify image type
if [[ "${IMAGE_TYPE}" == "cpu" ]]; then
DOCKERFILE="tensorflow/tools/docker/Dockerfile"
elif [[ "${IMAGE_TYPE}" == "gpu" ]]; then
DOCKERFILE="tensorflow/tools/docker/Dockerfile.gpu"
elif [[ "${IMAGE_TYPE}" == "rocm" ]]; then
DOCKERFILE="tensorflow/tools/docker/Dockerfile.rocm"
else
die "Unrecognized image type: $1"
fi
# Verify docker binary existence
if [[ -z $(which docker) ]]; then
die "FAILED: docker binary unavailable"
fi
# Locate the base directory
BASE_DIR=$(upsearch "${DOCKERFILE}")
if [[ -z "${BASE_DIR}" ]]; then
die "FAILED: Unable to find the base directory where the dockerfile "\
"${DOCKERFILE} resides"
fi
echo "Base directory: ${BASE_DIR}"
pushd ${BASE_DIR} > /dev/null
# Build docker image
DOCKERFILE_PATH="${BASE_DIR}/${DOCKERFILE}"
DOCKERFILE_DIR="$(dirname ${DOCKERFILE_PATH})"
# Check to make sure that the whl file exists
test -f ${WHL_PATH} || \
die "whl file does not exist: ${WHL_PATH}"
TMP_WHL_DIR="${DOCKERFILE_DIR}/whl"
mkdir -p "${TMP_WHL_DIR}"
cp "${WHL_PATH}" "${TMP_WHL_DIR}/" || \
die "FAILED to copy whl file from ${WHL_PATH} to ${TMP_WHL_DIR}/"
docker build -t "${DOCKER_IMG_TAG}" -f "${DOCKERFILE_PATH}" \
"${DOCKERFILE_DIR}" || \
die "FAILED to build docker image from Dockerfile ${DOCKERFILE_PATH}"
# Clean up
rm -rf "${TMP_WHL_DIR}" || \
die "Failed to remove temporary directory ${TMP_WHL_DIR}"
# Add extra params for cuda devices and libraries for GPU container.
if [ "${IMAGE_TYPE}" == "gpu" ]; then
devices=$(\ls /dev/nvidia* | xargs -I{} echo '--device {}:{}')
libs=$(\ls /usr/lib/x86_64-linux-gnu/libcuda.* | xargs -I{} echo '-v {}:{}')
GPU_EXTRA_PARAMS="${devices} ${libs}"
elif [ "${IMAGE_TYPE}" == "rocm" ]; then
ROCM_EXTRA_PARAMS="--device=/dev/kfd --device=/dev/dri --group-add video \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size 16G"
else
GPU_EXTRA_PARAMS=""
ROCM_EXTRA_PARAMS=""
fi
# Run docker image with source directory mapped
docker run -v ${BASE_DIR}:/tensorflow-src -w /tensorflow-src \
${GPU_EXTRA_PARAMS} ${ROCM_EXTRA_PARAMS} \
"${DOCKER_IMG_TAG}" \
/bin/bash -c "tensorflow/tools/ci_build/builds/run_pip_tests.sh && "\
"tensorflow/tools/ci_build/builds/test_tutorials.sh && "\
"tensorflow/tools/ci_build/builds/integration_tests.sh"
RESULT=$?
popd > /dev/null
if [[ ${RESULT} == 0 ]]; then
echo "SUCCESS: Built and tested docker image: ${DOCKER_IMG_TAG}"
else
die "FAILED to build and test docker image: ${DOCKER_IMG_TAG}"
fi
+124
View File
@@ -0,0 +1,124 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
# This script runs integration tests on the TensorFlow source code
# using a pip installation.
#
# Usage: integration_tests.sh [--virtualenv]
#
# If the flag --virtualenv is set, the script will use "python" as the Python
# binary path. Otherwise, it will use tools/python_bin_path.sh to determine
# the Python binary path.
#
# This script obeys the following environment variables (if exists):
# TF_BUILD_INTEG_TEST_DENYLIST: Force skipping of specified integration tests
# listed in INTEG_TESTS below.
#
# List of all integration tests to run, separated by spaces
INTEG_TESTS="ffmpeg_lib"
if [[ -z "${TF_BUILD_INTEG_TEST_DENYLIST}" ]]; then
TF_BUILD_INTEG_TEST_DENYLIST=""
fi
echo ""
echo "=== Integration Tests ==="
echo "TF_BUILD_INTEG_TEST_DENYLIST = \"${TF_BUILD_INTEG_TEST_DENYLIST}\""
# Timeout (in seconds) for each integration test
TIMEOUT=1800
INTEG_TEST_ROOT="$(mktemp -d)"
LOGS_DIR=pip_test/integration_tests/logs
# Current script directory
SCRIPT_DIR=$( cd ${0%/*} && pwd -P )
source "${SCRIPT_DIR}/builds_common.sh"
# Helper functions
cleanup() {
rm -rf $INTEG_TEST_ROOT
}
die() {
echo $@
cleanup
exit 1
}
# Determine the binary path for "timeout"
TIMEOUT_BIN="timeout"
if [[ -z "$(which ${TIMEOUT_BIN})" ]]; then
TIMEOUT_BIN="gtimeout"
if [[ -z "$(which ${TIMEOUT_BIN})" ]]; then
die "Unable to locate binary path for timeout command"
fi
fi
echo "Binary path for timeout: \"$(which ${TIMEOUT_BIN})\""
# Avoid permission issues outside Docker containers
umask 000
mkdir -p "${LOGS_DIR}" || die "Failed to create logs directory"
mkdir -p "${INTEG_TEST_ROOT}" || die "Failed to create test directory"
if [[ "$1" == "--virtualenv" ]]; then
PYTHON_BIN_PATH="$(which python)"
else
source tools/python_bin_path.sh
fi
if [[ -z "${PYTHON_BIN_PATH}" ]]; then
die "PYTHON_BIN_PATH was not provided. If this is not virtualenv, "\
"did you run configure?"
else
echo "Binary path for python: \"$PYTHON_BIN_PATH\""
fi
# Determine the TensorFlow installation path
# pushd/popd avoids importing TensorFlow from the source directory.
pushd /tmp > /dev/null
TF_INSTALL_PATH=$(dirname \
$("${PYTHON_BIN_PATH}" -c "import tensorflow as tf; print(tf.__file__)"))
popd > /dev/null
echo "Detected TensorFlow installation path: ${TF_INSTALL_PATH}"
TEST_DIR="pip_test/integration"
mkdir -p "${TEST_DIR}" || \
die "Failed to create test directory: ${TEST_DIR}"
# -----------------------------------------------------------
# ffmpeg_lib_test
test_ffmpeg_lib() {
# If FFmpeg is not installed then run a test that assumes it is not installed.
if [[ -z "$(which ffmpeg)" ]]; then
bazel test tensorflow/contrib/ffmpeg/default:ffmpeg_lib_uninstalled_test
return $?
else
bazel test tensorflow/contrib/ffmpeg/default:ffmpeg_lib_installed_test \
tensorflow/contrib/ffmpeg:decode_audio_op_test \
tensorflow/contrib/ffmpeg:encode_audio_op_test
return $?
fi
}
# Run the integration tests
test_runner "integration test-on-install" \
"${INTEG_TESTS}" "${TF_BUILD_INTEG_TEST_DENYLIST}" "${LOGS_DIR}"
@@ -0,0 +1,114 @@
#!/bin/bash
# Copyright 2016 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.
# ==============================================================================
# Pip install TensorFlow and run basic test on the pip package.
set -e
set -x
# Get size check function
source tensorflow/tools/ci_build/release/common.sh
function run_smoke_test() {
if [[ -z "${WHL_NAME}" ]]; then
echo "TF WHL path not given, unable to install and test."
exit 1
fi
# Upload the PIP package if whl test passes.
if [ ${IN_VENV} -eq 0 ]; then
VENV_TMP_DIR=$(mktemp -d)
${PYTHON_BIN_PATH} -m pip install virtualenv
${PYTHON_BIN_PATH} -m virtualenv -p ${PYTHON_BIN_PATH} "${VENV_TMP_DIR}" || \
die "FAILED: Unable to create virtualenv"
source "${VENV_TMP_DIR}/bin/activate" || \
die "FAILED: Unable to activate virtualenv "
fi
# install tensorflow
python -m pip install ${WHL_NAME} || \
die "pip install (forcing to reinstall tensorflow) FAILED"
echo "Successfully installed pip package ${WHL_NAME}"
# Test TensorflowFlow imports
test_tf_imports
# Test TensorFlow whl file size
test_tf_whl_size ${WHL_NAME}
RESULT=$?
# Upload the PIP package if whl test passes.
if [ ${IN_VENV} -eq 0 ]; then
# Deactivate from virtualenv.
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."
sudo rm -rf "${KOKORO_GFILE_DIR}/venv"
fi
return $RESULT
}
function test_tf_imports() {
TMP_DIR=$(mktemp -d)
pushd "${TMP_DIR}"
# test for basic import and perform tf.add operation.
RET_VAL=$(python -c "import tensorflow as tf; t1=tf.constant([1,2,3,4]); t2=tf.constant([5,6,7,8]); print(tf.add(t1,t2).shape)")
if ! [[ ${RET_VAL} == *'(4,)'* ]]; then
echo "Unexpected return value: ${RET_VALUE}"
echo "PIP test on virtualenv FAILED, will not upload ${WHL_NAME} package."
return 1
fi
# test basic keras is available
RET_VAL=$(python -c "import tensorflow as tf; print(tf.keras.__name__)")
if ! [[ ${RET_VAL} == *'keras.api'* ]]; then
echo "Unexpected return value: ${RET_VALUE}"
echo "PIP test on virtualenv FAILED, will not upload ${WHL_NAME} package."
return 1
fi
# similar test for estimator
RET_VAL=$(python -c "import tensorflow as tf; print(tf.estimator.__name__)")
if ! [[ ${RET_VAL} == *'tensorflow_estimator.python.estimator.api._v2.estimator'* ]]; then
echo "Unexpected return value: ${RET_VALUE}"
echo "PIP test on virtualenv FAILED, will not upload ${WHL_NAME} package."
return 1
fi
RESULT=$?
# TODO(b/210940071): Debug import order. Ignore returned errors.
set +e
python -m pip install "google-cloud-bigquery<=3.3.1"
$(python -c "from google.cloud.bigquery_v2 import types; import tensorflow")
$(python -c "import tensorflow; from google.cloud.bigquery_v2 import types")
set -e
popd
return $RESULT
}
###########################################################################
# Main
###########################################################################
IN_VENV=$(python -c 'import sys; print("1" if sys.version_info.major == 3 and sys.prefix != sys.base_prefix else "0")')
WHL_NAME=${1}
run_smoke_test
+784
View File
@@ -0,0 +1,784 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
# Build the Python PIP installation package for TensorFlow and install
# the package.
#
# Usage:
# pip_new.sh
#
# Required step(s):
# Run configure.py prior to running this script.
#
# Required environment variable(s):
# CONTAINER_TYPE: (CPU | GPU)
# OS_TYPE: (UBUNTU | MACOS)
# TF_PYTHON_VERSION: ( python3.6 | python3.7 | python3.8 )
# TF_BUILD_FLAGS: Bazel build flags.
# e.g. TF_BUILD_FLAGS="--config=opt"
# TF_TEST_FLAGS: Bazel test flags.
# e.g. TF_TEST_FLAGS="--verbose_failures=true \
# --build_tests_only --test_output=errors"
# TF_TEST_FILTER_TAGS: Filtering tags for bazel tests. More specifically,
# input tags for `--test_filter_tags` flag.
# e.g. TF_TEST_FILTER_TAGS="no_pip,-nomac,no_oss"
# TF_TEST_TARGETS: Bazel test targets.
# e.g. TF_TEST_TARGETS="//tensorflow/... \
# -//tensorflow/contrib/... \
# -//tensorflow/python/..."
# IS_NIGHTLY: Nightly run flag.
# e.g. IS_NIGHTLY=1 # nightly runs
# e.g. IS_NIGHTLY=0 # non-nightly runs
#
# Optional environment variables. If provided, overwrites any default values.
# TF_PIP_TESTS: PIP tests to run. If NOT specified, skips all tests.
# e.g. TF_PIP_TESTS="test_pip_virtualenv_clean \
# test_pip_virtualenv_clean \
# test_pip_virtualenv_oss_serial"
# TF_PROJECT_NAME: Name of the project. This string will be pass onto
# the wheel file name. For nightly builds, it will be
# overwritten to 'tf_nightly'. For gpu builds, '_gpu'
# will be appended.
# e.g. TF_PROJECT_NAME="tensorflow"
# e.g. TF_PROJECT_NAME="tf_nightly_gpu"
# TF_PIP_TEST_ROOT: Root directory for building and testing pip pkgs.
# e.g. TF_PIP_TEST_ROOT="pip_test"
# TF_BUILD_BOTH_GPU_PACKAGES: (1 | 0)
# 1 will build both tensorflow (w/ gpu support)
# and tensorflow-gpu pip package. Will
# automatically handle adding/removing of _gpu
# suffix depending on what project name was
# passed. Only work for Ubuntu.
# TF_BUILD_BOTH_CPU_PACKAGES: (1 | 0)
# 1 will build both tensorflow (no gpu support)
# and tensorflow-cpu pip package. Will
# automatically handle adding/removing of _cpu
# suffix depending on what project name was
# passed. Only work for MacOS
# AUDITWHEEL_TARGET_PLAT: Manylinux platform tag that is to be used for
# tagging the linux wheel files. By default, it is
# set to `manylinux2010` . For manylinux2014
# builds, change to `manylinux2014`.
#
# To-be-deprecated variable(s).
# GIT_TAG_OVERRIDE: Values for `--git_tag_override`. This flag gets passed
# in as `--action_env` for bazel build and tests.
# TF_BUILD_INSTALL_EXTRA_PIP_PACKAGES:
# Additional pip packages to be installed.
# Caveat: pip version needs to be checked prior.
#
# ==============================================================================
# set bash options
set -e
set -x
###########################################################################
# General helper function(s)
###########################################################################
# Strip leading and trailing whitespaces
str_strip () {
echo -e "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
}
# Convert string to all lower case
lowercase() {
if [[ -z "${1}" ]]; then
die "Nothing to convert to lowercase. No argument given."
fi
echo "${1}" | tr '[:upper:]' '[:lower:]'
}
check_global_vars() {
# Check container type
if ! [[ ${CONTAINER_TYPE} == "cpu" ]] && \
! [[ ${CONTAINER_TYPE} == "rocm" ]] && \
! [[ ${CONTAINER_TYPE} == "gpu" ]]; then
die "Error: Provided CONTAINER_TYPE \"${CONTAINER_TYPE}\" "\
"is not supported."
fi
# Check OS type
if ! [[ ${OS_TYPE} == "ubuntu" ]] && \
! [[ ${OS_TYPE} == "macos" ]]; then
die "Error: Provided OS_TYPE \"${OS_TYPE}\" is not supported."
fi
# Check build flags
if [[ -z ${TF_BUILD_FLAGS} ]]; then
die "Error: TF_BUILD_FLAGS is not specified."
fi
# Check test flags
if [[ -z ${TF_TEST_FLAGS} ]]; then
die "Error: TF_TEST_FLAGS is not specified."
fi
# Check test filter tags
if [[ -z ${TF_TEST_FILTER_TAGS} ]]; then
die "Error: TF_TEST_FILTER_TAGS is not specified."
fi
# Check test targets
if [[ -z ${TF_TEST_TARGETS} ]]; then
die "Error: TF_TEST_TARGETS is not specified."
fi
# Check nightly status
if [[ -z ${IS_NIGHTLY} ]]; then
die "Error: IS_NIGHTLY is not specified."
fi
}
add_test_filter_tag() {
EMPTY=""
while true; do
FILTER="${1:$EMPTY}"
if ! [[ $TF_TEST_FILTER_TAGS == *"${FILTER}"* ]]; then
TF_TEST_FILTER_TAGS="${FILTER},${TF_TEST_FILTER_TAGS}"
fi
shift
if [[ -z "${1}" ]]; then
break
fi
done
}
remove_test_filter_tag() {
EMPTY=""
while true; do
FILTER="${1:$EMPTY}"
TF_TEST_FILTER_TAGS="$(echo ${TF_TEST_FILTER_TAGS} | sed -e 's/^'${FILTER}',//g' -e 's/,'${FILTER}'//g')"
shift
if [[ -z "${1}" ]]; then
break
fi
done
}
# Clean up bazel build & test flags with proper configuration.
update_bazel_flags() {
# Add git tag override flag if necessary.
GIT_TAG_STR=" --action_env=GIT_TAG_OVERRIDE"
if [[ -z "${GIT_TAG_OVERRIDE}" ]] && \
! [[ ${TF_BUILD_FLAGS} = *${GIT_TAG_STR}* ]]; then
TF_BUILD_FLAGS+="${GIT_TAG_STR}"
fi
# Clean up whitespaces
TF_BUILD_FLAGS=$(str_strip "${TF_BUILD_FLAGS}")
TF_TEST_FLAGS=$(str_strip "${TF_TEST_FLAGS}")
# Cleaned bazel flags
echo "Bazel build flags (cleaned):\n" "${TF_BUILD_FLAGS}"
echo "Bazel test flags (cleaned):\n" "${TF_TEST_FLAGS}"
}
update_test_filter_tags() {
# Add test filter tags
# This script is for validating built PIP packages. Add pip tags.
add_test_filter_tag -no_pip -nopip
# MacOS filter tags
if [[ ${OS_TYPE} == "macos" ]]; then
remove_test_filter_tag nomac no_mac mac_excluded
add_test_filter_tag -nomac -no_mac -mac_excluded
fi
echo "Final test filter tags: ${TF_TEST_FILTER_TAGS}"
}
# Check currently running python and pip version
check_python_pip_version() {
# Check if only the major version of python is provided by the user.
MAJOR_VER_ONLY=0
if [[ ${#PYTHON_VER} -lt 9 ]]; then
# User only provided major version (e.g. 'python3' instead of 'python3.7')
MAJOR_VER_ONLY=1
fi
# Retrieve only the version number of the user requested python.
PYTHON_VER_REQUESTED=${PYTHON_VER:6:3}
echo "PYTHON_VER_REQUESTED: ${PYTHON_VER_REQUESTED}"
# Retrieve only the version numbers of the python & pip in use currently.
PYTHON_VER_IN_USE=$(python --version 2>&1)
PYTHON_VER_IN_USE=${PYTHON_VER_IN_USE:7:3}
PIP_VER_IN_USE=$(${PIP_BIN_PATH} --version)
PIP_VER_IN_USE=${PIP_VER_IN_USE:${#PIP_VER_IN_USE}-4:3}
# If only major versions are applied, drop minor versions.
if [[ $MAJOR_VER_ONLY == 1 ]]; then
PYTHON_VER_IN_USE=${PYTHON_VER_IN_USE:0:1}
PIP_VER_IN_USE=${PIP_VER_IN_USE:0:1}
fi
# Check if all versions match.
echo -e "User requested python version: '${PYTHON_VER_REQUESTED}'\n" \
"Detected python version in use: '${PYTHON_VER_IN_USE}'\n"\
"Detected pip version in use: '${PIP_VER_IN_USE}'"
if ! [[ $PYTHON_VER_REQUESTED == $PYTHON_VER_IN_USE ]]; then
die "Error: Mismatch in python versions detected."
else:
echo "Python and PIP versions in use match the requested."
fi
}
# Write an entry to the sponge key-value store for this job.
write_to_sponge() {
# The location of the key-value CSV file sponge imports.
TF_SPONGE_CSV="${KOKORO_ARTIFACTS_DIR}/custom_sponge_config.csv"
echo "$1","$2" >> "${TF_SPONGE_CSV}"
}
###########################################################################
# Setup: directories, local/global variables
###########################################################################
# Script directory and source necessary files.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds_common.sh"
# Required global variables
# Checks on values for these vars are done in "Build TF PIP Package" section.
CONTAINER_TYPE=$(lowercase "${CONTAINER_TYPE}")
OS_TYPE=$(lowercase "${OS_TYPE}")
PYTHON_VER=$(lowercase "${TF_PYTHON_VERSION}")
# Python bin path
if [[ -z "$PYTHON_BIN_PATH" ]]; then
die "Error: PYTHON_BIN_PATH was not provided. Did you run configure?"
fi
# Set optional environment variables; set to default in case not user defined.
DEFAULT_PIP_TESTS="" # Do not run any tests by default
DEFAULT_PROJECT_NAME="tensorflow"
DEFAULT_PIP_TEST_ROOT="pip_test"
DEFAULT_BUILD_BOTH_GPU_PACKAGES=0
DEFAULT_BUILD_BOTH_CPU_PACKAGES=0
DEFAULT_AUDITWHEEL_TARGET_PLAT="manylinux2010"
# Take in optional global variables
PIP_TESTS=${TF_PIP_TESTS:-$DEFAULT_PIP_TESTS}
PROJECT_NAME=${TF_PROJECT_NAME:-$DEFAULT_PROJECT_NAME}
PIP_TEST_ROOT=${TF_PIP_TEST_ROOT:-$DEFAULT_PIP_TEST_ROOT}
BUILD_BOTH_GPU_PACKAGES=${TF_BUILD_BOTH_GPU_PACKAGES:-$DEFAULT_BUILD_BOTH_GPU_PACKAGES}
BUILD_BOTH_CPU_PACKAGES=${TF_BUILD_BOTH_CPU_PACKAGES:-$DEFAULT_BUILD_BOTH_CPU_PACKAGES}
AUDITWHEEL_TARGET_PLAT=${TF_AUDITWHEEL_TARGET_PLAT:-$DEFAULT_AUDITWHEEL_TARGET_PLAT}
# Override breaking change in setuptools v60 (https://github.com/pypa/setuptools/pull/2896)
export SETUPTOOLS_USE_DISTUTILS=stdlib
# Local variables
PIP_WHL_DIR="${KOKORO_ARTIFACTS_DIR}/tensorflow/${PIP_TEST_ROOT}/whl"
mkdir -p "${PIP_WHL_DIR}"
PIP_WHL_DIR=$(realpath "${PIP_WHL_DIR}") # Get absolute path
WHL_PATH=""
# Determine the major.minor versions of python being used (e.g., 3.7).
# Useful for determining the directory of the local pip installation.
PY_MAJOR_MINOR_VER=$(${PYTHON_BIN_PATH} -c "print(__import__('sys').version)" 2>&1 | awk '{ print $1 }' | head -n 1 | cut -d. -f1-2)
if [[ -z "${PY_MAJOR_MINOR_VER}" ]]; then
die "ERROR: Unable to determine the major.minor version of Python."
fi
echo "Python binary path to be used in PIP install: ${PYTHON_BIN_PATH} "\
"(Major.Minor version: ${PY_MAJOR_MINOR_VER})"
PYTHON_BIN_PATH_INIT=${PYTHON_BIN_PATH}
PIP_BIN_PATH="$(which pip${PY_MAJOR_MINOR_VER})"
# PIP packages
INSTALL_EXTRA_PIP_PACKAGES="h5py portpicker scipy scikit-learn ${TF_BUILD_INSTALL_EXTRA_PIP_PACKAGES}"
###########################################################################
# Build TF PIP Package
###########################################################################
# First remove any already existing binaries for a clean start and test.
if [[ -d ${PIP_TEST_ROOT} ]]; then
echo "Test root directory ${PIP_TEST_ROOT} already exists. Deleting it."
sudo rm -rf ${PIP_TEST_ROOT}
fi
# Check that global variables are properly set.
check_global_vars
# Check if in a virtualenv and exit if yes.
# TODO(rameshsampath): Python 3.10 has pip conflicts when using global env, so build in virtualenv
# Once confirmed to work, run builds for all python env in a virtualenv
if [[ "x${PY_MAJOR_MINOR_VER}x" != "x3.10x" ]]; then
IN_VENV=$(python -c 'import sys; print("1" if sys.version_info.major == 3 and sys.prefix != sys.base_prefix else "0")')
if [[ "$IN_VENV" == "1" ]]; then
echo "It appears that we are already in a virtualenv. Deactivating..."
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."
fi
fi
# Obtain the path to python binary as written by ./configure if it was run.
if [[ -e tools/python_bin_path.sh ]]; then
source tools/python_bin_path.sh
fi
# Assume PYTHON_BIN_PATH is exported by the script above or the caller.
if [[ -z "$PYTHON_BIN_PATH" ]]; then
die "PYTHON_BIN_PATH was not provided. Did you run configure?"
fi
if [[ "$IS_NIGHTLY" == 1 ]]; then
${PYTHON_BIN_PATH} -m pip install tb-nightly
else
${PYTHON_BIN_PATH} -m pip install tensorboard
fi
if [[ "x${PY_MAJOR_MINOR_VER}x" == "x3.8x" ]]; then
${PYTHON_BIN_PATH} -m pip uninstall -y protobuf
${PYTHON_BIN_PATH} -m pip install "protobuf < 4"
fi
# Bazel build the file.
PIP_BUILD_TARGET="//tensorflow/tools/pip_package:build_pip_package"
# Clean bazel cache.
bazel clean
# Clean up and update bazel flags
update_bazel_flags
# Build. This outputs the file `build_pip_package`.
bazel build \
--action_env=PYTHON_BIN_PATH=${PYTHON_BIN_PATH} \
${TF_BUILD_FLAGS} \
${PIP_BUILD_TARGET} \
|| die "Error: Bazel build failed for target: '${PIP_BUILD_TARGET}'"
###########################################################################
# Test function(s)
###########################################################################
test_pip_virtualenv() {
# Get args
WHL_PATH=$1
shift
VENV_DIR_NAME=$1
shift
TEST_TYPE_FLAG=$1
# Check test type args
if ! [[ ${TEST_TYPE_FLAG} == "--oss_serial" ]] && \
! [[ ${TEST_TYPE_FLAG} == "--clean" ]] && \
! [[ ${TEST_TYPE_FLAG} == "" ]]; then
die "Error: Wrong test type given. TEST_TYPE_FLAG=${TEST_TYPE_FLAG}"
fi
# Create virtualenv directory for test
VENV_DIR="${PIP_TEST_ROOT}/${VENV_DIR_NAME}"
# Activate virtualenv
create_activate_virtualenv ${TEST_TYPE_FLAG} ${VENV_DIR}
# Install TF with pip
TIME_START=$SECONDS
install_tensorflow_pip "${WHL_PATH}"
TIME_ELAPSED=$(($SECONDS - $TIME_START))
echo "Time elapsed installing tensorflow = ${TIME_ELAPSED} seconds"
# cd to a temporary directory to avoid picking up Python files in the source
# tree.
TMP_DIR=$(mktemp -d)
pushd "${TMP_DIR}"
# Run a quick check on tensorflow installation.
RET_VAL=$(python -c "import tensorflow as tf; t1=tf.constant([1,2,3,4]); t2=tf.constant([5,6,7,8]); print(tf.add(t1,t2).shape)")
# Return to original directory. Remove temp dirs.
popd
sudo rm -rf "${TMP_DIR}"
# Check result to see if tensorflow is properly installed.
if ! [[ ${RET_VAL} == *'(4,)'* ]]; then
echo "PIP test on virtualenv (non-clean) FAILED"
return 1
fi
# Install extra pip packages, if specified.
for PACKAGE in ${INSTALL_EXTRA_PIP_PACKAGES}; do
echo "Installing extra pip package required by test-on-install: ${PACKAGE}"
${PIP_BIN_PATH} install ${PACKAGE}
if [[ $? != 0 ]]; then
echo "${PIP_BIN_PATH} install ${PACKAGE} FAILED."
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."
return 1
fi
done
# Run bazel test.
run_test_with_bazel ${TEST_TYPE_FLAG}
RESULT=$?
# Deactivate from virtualenv.
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."
sudo rm -rf "${VENV_DIR}"
return $RESULT
}
###########################################################################
# Test helper function(s)
###########################################################################
create_activate_virtualenv() {
VIRTUALENV_FLAGS="--system-site-packages"
if [[ "${1}" == "--clean" ]]; then
VIRTUALENV_FLAGS=""
shift
elif [[ "${1}" == "--oss_serial" ]]; then
shift
fi
VIRTUALENV_DIR="${1}"
if [[ -d "${VIRTUALENV_DIR}" ]]; then
if sudo rm -rf "${VIRTUALENV_DIR}"
then
echo "Removed existing virtualenv directory: ${VIRTUALENV_DIR}"
else
die "Failed to remove existing virtualenv directory: ${VIRTUALENV_DIR}"
fi
fi
if mkdir -p "${VIRTUALENV_DIR}"
then
echo "Created virtualenv directory: ${VIRTUALENV_DIR}"
else
die "FAILED to create virtualenv directory: ${VIRTUALENV_DIR}"
fi
# Use the virtualenv from the default python version (i.e., python-virtualenv)
# to create the virtualenv directory for testing. Use the -p flag to specify
# the python version inside the to-be-created virtualenv directory.
${PYTHON_BIN_PATH_INIT} -m virtualenv -p ${PYTHON_BIN_PATH_INIT} ${VIRTUALENV_FLAGS} ${VIRTUALENV_DIR} || \
${PYTHON_BIN_PATH_INIT} -m venv ${VIRTUALENV_DIR} || \
die "FAILED: Unable to create virtualenv"
source "${VIRTUALENV_DIR}/bin/activate" || \
die "FAILED: Unable to activate virtualenv in ${VIRTUALENV_DIR}"
# Update .tf_configure.bazelrc with venv python path for bazel test.
PYTHON_BIN_PATH="$(which python)"
yes "" | ./configure
}
install_tensorflow_pip() {
if [[ -z "${1}" ]]; then
die "Please provide a proper wheel file path."
fi
# Set path to pip.
PIP_BIN_PATH="${PYTHON_BIN_PATH} -m pip"
# Print python and pip bin paths
echo "PYTHON_BIN_PATH to be used to install the .whl: ${PYTHON_BIN_PATH}"
echo "PIP_BIN_PATH to be used to install the .whl: ${PIP_BIN_PATH}"
# Upgrade pip so it supports tags such as cp27mu, manylinux2010 etc.
echo "Upgrade pip in virtualenv"
# NOTE: pip install --upgrade pip leads to a documented TLS issue for
# some versions in python
curl https://bootstrap.pypa.io/get-pip.py | ${PYTHON_BIN_PATH} || \
die "Error: pip install (get-pip.py) FAILED"
# Check that requested python version matches configured one.
check_python_pip_version
# setuptools v60.0.0 introduced a breaking change on how distutils is linked
# https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6000
${PIP_BIN_PATH} install --upgrade "setuptools" || \
die "Error: setuptools install, upgrade FAILED"
# Force tensorflow reinstallation. Otherwise it may not get installed from
# last build if it had the same version number as previous build.
PIP_FLAGS="--upgrade --force-reinstall"
${PIP_BIN_PATH} install ${PIP_FLAGS} ${WHL_PATH} || \
die "pip install (forcing to reinstall tensorflow) FAILED"
echo "Successfully installed pip package ${WHL_PATH}"
# Install the future package in the virtualenv. Installing it in user system
# packages does not appear to port it over when creating a virtualenv.
# ImportError: No module named builtins
${PIP_BIN_PATH} install --upgrade "future>=0.17.1" || \
die "Error: future install, upgrade FAILED"
# Install the gast package in the virtualenv. Installing it in user system
# packages does not appear to port it over when creating a virtualenv.
${PIP_BIN_PATH} install --upgrade "gast==0.4.0" || \
die "Error: gast install, upgrade FAILED"
}
run_test_with_bazel() {
IS_OSS_SERIAL=0
if [[ "${1}" == "--oss_serial" ]]; then
IS_OSS_SERIAL=1
fi
TF_GPU_COUNT=${TF_GPU_COUNT:-4}
# PIP tests should have a "different" path. Different than the one we place
# virtualenv, because we are deleting and recreating it here.
PIP_TEST_PREFIX=bazel_pip
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
sudo rm -rf $TEST_ROOT
mkdir -p $TEST_ROOT
ln -s $(pwd)/tensorflow $TEST_ROOT/tensorflow
if [[ "${IS_OSS_SERIAL}" == "1" ]]; then
remove_test_filter_tag -no_oss
remove_test_filter_tag -oss_excluded
remove_test_filter_tag -oss_serial
add_test_filter_tag oss_serial
else
add_test_filter_tag -oss_serial
fi
# Clean the bazel cache
bazel clean
# Clean up flags before running bazel commands
update_bazel_flags
# Clean up and update test filter tags
update_test_filter_tags
# Figure out how many concurrent tests we can run and do run the tests.
BAZEL_PARALLEL_TEST_FLAGS=""
if [[ $CONTAINER_TYPE == "gpu" ]] || [[ $CONTAINER_TYPE == "rocm" ]]; then
# Number of test threads is the number of GPU cards available.
if [[ $OS_TYPE == "macos" ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=1"
else
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=${TF_GPU_COUNT} \
--run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute"
fi
else
# Number of test threads is the number of physical CPUs.
if [[ $OS_TYPE == "macos" ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=$(sysctl -n hw.ncpu)"
else
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=$(grep -c ^processor /proc/cpuinfo)"
fi
fi
if [[ ${IS_OSS_SERIAL} == 1 ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=1"
fi
TEST_TARGETS_SYMLINK=""
for TARGET in ${TF_TEST_TARGETS[@]}; do
TARGET_NEW=$(echo ${TARGET} | sed -e "s/\/\//\/\/${PIP_TEST_PREFIX}\//g")
TEST_TARGETS_SYMLINK+="${TARGET_NEW} "
done
echo "Test targets (symlink): ${TEST_TARGETS_SYMLINK}"
# Run the test.
bazel test --build_tests_only ${TF_TEST_FLAGS} ${BAZEL_PARALLEL_TEST_FLAGS} --test_tag_filters=${TF_TEST_FILTER_TAGS} -k -- ${TEST_TARGETS_SYMLINK}
unlink ${TEST_ROOT}/tensorflow
}
run_all_tests() {
WHL_PATH=$1
if [[ -z "${PIP_TESTS}" ]]; then
echo "No test was specified to run. Skipping all tests."
return 0
fi
FAIL_COUNTER=0
PASS_COUNTER=0
for TEST in ${PIP_TESTS[@]}; do
# Run tests.
case "${TEST}" in
"test_pip_virtualenv_clean")
test_pip_virtualenv ${WHL_PATH} venv_clean --clean
;;
"test_pip_virtualenv_non_clean")
test_pip_virtualenv ${WHL_PATH} venv
;;
"test_pip_virtualenv_oss_serial")
test_pip_virtualenv ${WHL_PATH} venv_oss --oss_serial
;;
*)
die "No matching test ${TEST} was found. Stopping test."
;;
esac
# Check and update the results.
RETVAL=$?
# Update results counter
if [ ${RETVAL} -eq 0 ]; then
echo "Test (${TEST}) PASSED. (PASS COUNTER: ${PASS_COUNTER})"
PASS_COUNTER=$(($PASS_COUNTER+1))
else
echo "Test (${TEST}) FAILED. (FAIL COUNTER: ${FAIL_COUNTER})"
FAIL_COUNTER=$(($FAIL_COUNTER+1))
fi
done
printf "${PASS_COUNTER} PASSED | ${FAIL_COUNTER} FAILED"
if [[ "${FAIL_COUNTER}" == "0" ]]; then
printf "PIP tests ${COLOR_GREEN}PASSED${COLOR_NC}\n"
return 0
else:
printf "PIP tests ${COLOR_RED}FAILED${COLOR_NC}\n"
return 1
fi
}
###########################################################################
# Build TF PIP Wheel file
###########################################################################
# Update the build flags for building whl.
# Flags: GPU, OS, tf_nightly, project name
GPU_FLAG=""
NIGHTLY_FLAG=""
# TF Nightly flag
if [[ "$IS_NIGHTLY" == 1 ]]; then
# If 'nightly' is not specified in the project name already, then add.
if ! [[ $PROJECT_NAME == *"nightly"* ]]; then
echo "WARNING: IS_NIGHTLY=${IS_NIGHTLY} but requested project name \
(PROJECT_NAME=${PROJECT_NAME}) does not include 'nightly' string. \
Renaming it to 'tf_nightly'."
PROJECT_NAME="tf_nightly"
fi
NIGHTLY_FLAG="--nightly_flag"
fi
# CPU / GPU flag
if [[ ${CONTAINER_TYPE} == "gpu" ]]; then
GPU_FLAG="--gpu"
if ! [[ $PROJECT_NAME == *"gpu"* ]]; then
# Only update PROJECT_NAME if TF_PROJECT_NAME is not set
if [[ -z "${TF_PROJECT_NAME}" ]]; then
echo "WARNING: GPU is specified but requested project name (PROJECT_NAME=${PROJECT_NAME}) \
does not include 'gpu'. Appending '_gpu' to the project name."
PROJECT_NAME="${PROJECT_NAME}_gpu"
fi
fi
fi
if [[ ${CONTAINER_TYPE} == "rocm" ]]; then
GPU_FLAG="--rocm"
if ! [[ $PROJECT_NAME == *"rocm"* ]]; then
# Only update PROJECT_NAME if TF_PROJECT_NAME is not set
if [[ -z "${TF_PROJECT_NAME}" ]]; then
echo "WARNING: ROCM is specified but requested project name (PROJECT_NAME=${PROJECT_NAME}) \
does not include 'rocm'. Appending '_rocm' to the project name."
PROJECT_NAME="${PROJECT_NAME}_rocm"
fi
fi
fi
./bazel-bin/tensorflow/tools/pip_package/build_pip_package ${PIP_WHL_DIR} ${GPU_FLAG} ${NIGHTLY_FLAG} "--project_name" ${PROJECT_NAME} || die "build_pip_package FAILED"
PY_DOTLESS_MAJOR_MINOR_VER=$(echo $PY_MAJOR_MINOR_VER | tr -d '.')
if [[ $PY_DOTLESS_MAJOR_MINOR_VER == "2" ]]; then
PY_DOTLESS_MAJOR_MINOR_VER="27"
fi
# Set wheel path and verify that there is only one .whl file in the path.
WHL_PATH=$(ls "${PIP_WHL_DIR}"/"${PROJECT_NAME}"-*"${PY_DOTLESS_MAJOR_MINOR_VER}"*"${PY_DOTLESS_MAJOR_MINOR_VER}"*.whl)
if [[ $(echo "${WHL_PATH}" | wc -w) -ne 1 ]]; then
echo "ERROR: Failed to find exactly one built TensorFlow .whl file in "\
"directory: ${PIP_WHL_DIR}"
fi
WHL_DIR=$(dirname "${WHL_PATH}")
# Print the size of the wheel file and log to sponge.
WHL_SIZE=$(ls -l ${WHL_PATH} | awk '{print $5}')
echo "Size of the PIP wheel file built: ${WHL_SIZE}"
write_to_sponge TF_INFO_WHL_SIZE ${WHL_SIZE}
# Build the other GPU package.
if [[ "$BUILD_BOTH_GPU_PACKAGES" -eq "1" ]] || [[ "$BUILD_BOTH_CPU_PACKAGES" -eq "1" ]]; then
if [[ "$BUILD_BOTH_GPU_PACKAGES" -eq "1" ]] && [[ "$BUILD_BOTH_CPU_PACKAGES" -eq "1" ]]; then
die "ERROR: TF_BUILD_BOTH_GPU_PACKAGES and TF_BUILD_BOTH_GPU_PACKAGES cannot both be set. No additional package will be built."
fi
echo "====================================="
if [[ "$BUILD_BOTH_GPU_PACKAGES" -eq "1" ]]; then
if ! [[ ${OS_TYPE} == "ubuntu" ]]; then
die "ERROR: pip_new.sh only support building both GPU wheels on ubuntu."
fi
echo "Building the other GPU pip package."
PROJECT_SUFFIX="gpu"
else
if ! [[ ${OS_TYPE} == "macos" ]]; then
die "ERROR: pip_new.sh only support building both CPU wheels on macos."
fi
echo "Building the other CPU pip package."
PROJECT_SUFFIX="cpu"
fi
# Check container type
if ! [[ ${CONTAINER_TYPE} == ${PROJECT_SUFFIX} ]]; then
die "Error: CONTAINER_TYPE needs to be \"${PROJECT_SUFFIX}\" to build ${PROJECT_SUFFIX} packages. Got"\
"\"${CONTAINER_TYPE}\" instead."
fi
if [[ "$PROJECT_NAME" == *_${PROJECT_SUFFIX} ]]; then
NEW_PROJECT_NAME=${PROJECT_NAME}"_${PROJECT_SUFFIX}"
else
NEW_PROJECT_NAME="${PROJECT_NAME}_${PROJECT_SUFFIX}"
fi
echo "The given ${PROJECT_SUFFIX} \$PROJECT_NAME is ${PROJECT_NAME}. The additional ${PROJECT_SUFFIX}"\
"pip package will have project name ${NEW_PROJECT_NAME}."
./bazel-bin/tensorflow/tools/pip_package/build_pip_package ${PIP_WHL_DIR} ${GPU_FLAG} ${NIGHTLY_FLAG} "--project_name" ${NEW_PROJECT_NAME} || die "build_pip_package FAILED"
fi
# On MacOS we not have to rename the wheel because it is generated with the
# wrong tag.
if [[ ${OS_TYPE} == "macos" ]] ; then
for WHL_PATH in $(ls ${PIP_WHL_DIR}/*macosx_10_15_x86_64.whl); do
# change 10_15 to 10_14
NEW_WHL_PATH=${WHL_PATH/macosx_10_15/macosx_10_14}
mv ${WHL_PATH} ${NEW_WHL_PATH}
done
# Also change global WHL_PATH. Ignore above shadow and everywhere else
NEW_WHL_PATH=${WHL_PATH/macosx_10_15/macosx_10_14}
WHL_PATH=${NEW_WHL_PATH}
fi
# Run tests (if any is specified).
run_all_tests ${WHL_PATH}
if [[ ${OS_TYPE} == "ubuntu" ]] && \
! [[ ${CONTAINER_TYPE} == "rocm" ]] ; then
# Avoid Python3.6 abnormality by installing auditwheel here.
# TODO(rameshsampath) - Cleanup and remove the need for auditwheel install
# Python 3.10 requires auditwheel > 2 and its already installed in common.sh
if [[ $PY_MAJOR_MINOR_VER -ne "3.10" ]]; then
set +e
pip3 show auditwheel || "pip${PY_MAJOR_MINOR_VER}" show auditwheel
# For tagging wheels as manylinux2014, auditwheel needs to >= 3.0.0
pip3 install auditwheel==3.3.1 || "pip${PY_MAJOR_MINOR_VER}" install auditwheel==3.3.1
sudo pip3 install auditwheel==3.3.1 || \
sudo "pip${PY_MAJOR_MINOR_VER}" install auditwheel==3.3.1
set -e
fi
auditwheel --version
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}_$(uname -m) -w "${WHL_DIR}" "${WHL_PATH}"
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."
fi
done
fi
echo "EOF: Successfully ran pip_new.sh"
+110
View File
@@ -0,0 +1,110 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# =============================================================================
# Print build info, including info related to the machine, OS, build tools
# and TensorFlow source code. This can be used by build tools such as Jenkins.
# All info is printed on a single line, in JSON format, to workaround the
# limitation of Jenkins Description Setter Plugin that multi-line regex is
# not supported.
#
# Usage:
# print_build_info.sh (CONTAINER_TYPE) (COMMAND)
# e.g.,
# print_build_info.sh GPU bazel test -c opt --config=cuda //tensorflow/...
# Information about the command
CONTAINER_TYPE=$1
shift 1
COMMAND=("$@")
# Information about machine and OS
OS=$(uname)
KERNEL=$(uname -r)
ARCH=$(uname -p)
PROCESSOR=$(grep "model name" /proc/cpuinfo | head -1 | awk '{print substr($0, index($0, $4))}')
PROCESSOR_COUNT=$(grep "model name" /proc/cpuinfo | wc -l)
MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2, $3}')
SWAP_TOTAL=$(grep SwapTotal /proc/meminfo | awk '{print $2, $3}')
# Information about build tools
if [[ ! -z $(which bazel) ]]; then
BAZEL_VER=$(bazel version | head -1)
fi
if [[ ! -z $(which javac) ]]; then
JAVA_VER=$(javac -version 2>&1 | awk '{print $2}')
fi
if [[ ! -z $(which python) ]]; then
PYTHON_VER=$(python -V 2>&1 | awk '{print $2}')
fi
if [[ ! -z $(which g++) ]]; then
GPP_VER=$(g++ --version | head -1)
fi
if [[ ! -z $(which swig) ]]; then
SWIG_VER=$(swig -version > /dev/null | grep -m 1 . | awk '{print $3}')
fi
# Information about TensorFlow source
TF_FETCH_URL=$(git config --get remote.origin.url)
TF_HEAD=$(git rev-parse HEAD)
# NVIDIA & CUDA info
NVIDIA_DRIVER_VER=""
if [[ -f /proc/driver/nvidia/version ]]; then
NVIDIA_DRIVER_VER=$(head -1 /proc/driver/nvidia/version | awk '{print $(NF-6)}')
fi
CUDA_DEVICE_COUNT="0"
CUDA_DEVICE_NAMES=""
if [[ ! -z $(which nvidia-debugdump) ]]; then
CUDA_DEVICE_COUNT=$(nvidia-debugdump -l | grep "^Found [0-9]*.*device.*" | awk '{print $2}')
CUDA_DEVICE_NAMES=$(nvidia-debugdump -l | grep "Device name:.*" | awk '{print substr($0, index($0,\
$3)) ","}')
fi
CUDA_TOOLKIT_VER=""
if [[ ! -z $(which nvcc) ]]; then
CUDA_TOOLKIT_VER=$(nvcc -V | grep release | awk '{print $(NF)}')
fi
# Print info
echo "TF_BUILD_INFO = {"\
"container_type: \"${CONTAINER_TYPE}\", "\
"command: \"${COMMAND[*]}\", "\
"source_HEAD: \"${TF_HEAD}\", "\
"source_remote_origin: \"${TF_FETCH_URL}\", "\
"OS: \"${OS}\", "\
"kernel: \"${KERNEL}\", "\
"architecture: \"${ARCH}\", "\
"processor: \"${PROCESSOR}\", "\
"processor_count: \"${PROCESSOR_COUNT}\", "\
"memory_total: \"${MEM_TOTAL}\", "\
"swap_total: \"${SWAP_TOTAL}\", "\
"Bazel_version: \"${BAZEL_VER}\", "\
"Java_version: \"${JAVA_VER}\", "\
"Python_version: \"${PYTHON_VER}\", "\
"gpp_version: \"${GPP_VER}\", "\
"swig_version: \"${SWIG_VER}\", "\
"NVIDIA_driver_version: \"${NVIDIA_DRIVER_VER}\", "\
"CUDA_device_count: \"${CUDA_DEVICE_COUNT}\", "\
"CUDA_device_names: \"${CUDA_DEVICE_NAMES}\", "\
"CUDA_toolkit_version: \"${CUDA_TOOLKIT_VER}\""\
"}"
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
# This file runs a Python test file using specified Python binary, and store
# the test log, along with exit code and elapsed time in a log file.
#
# Usage: test_delegate.sh <PYTHON_BIN_PATH> <TEST_PATH> <TEST_LOG>
PYTHON_BIN_PATH=$1
TEST_PATH=$2
TEST_LOG=$3
# Current script directory
SCRIPT_DIR=$( cd ${0%/*} && pwd -P )
source "${SCRIPT_DIR}/builds_common.sh"
rm -f ${TEST_LOG}
TEST_DIR=$(dirname ${TEST_PATH})
cd ${TEST_DIR}
START_TIME=$(date +'%s%N')
${PYTHON_BIN_PATH} ${TEST_PATH} >${TEST_LOG} 2>&1
TEST_EXIT_CODE=$?
END_TIME=$(date +'%s%N')
ELAPSED=$(calc_elapsed_time "${START_TIME}" "${END_TIME}")
echo "${TEST_EXIT_CODE} ${ELAPSED}" >> ${TEST_LOG}
+179
View File
@@ -0,0 +1,179 @@
#!/bin/bash
# Copyright 2016 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.
#
# ==============================================================================
#
# Run the python unit tests from the source code on the pip installation.
#
# Usage:
# run_pip_tests.sh [--virtualenv] [--gpu] [--mac] [--oss_serial]
#
# If the flag --virtualenv is set, the script will use "python" as the Python
# binary path. Otherwise, it will use tools/python_bin_path.sh to determine
# the Python binary path.
#
# The --gpu flag informs the script that this is a GPU build, so that the
# appropriate test denylists can be applied accordingly.
#
# The --mac flag informs the script that this is running on mac. Mac does not
# have flock, so we should skip using parallel_gpu_execute on mac.
#
# The --oss_serial flag lets the script run only the py tests with the
# oss_serial tag, in a serial fashion, i.e., using the bazel flag
# --local_test_jobs=1
#
# TF_BUILD_APPEND_ARGUMENTS:
# Additional command line arguments for the bazel,
# pip.sh or android.sh command
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds_common.sh"
# Process input arguments
IS_VIRTUALENV=0
IS_GPU=0
IS_ROCM=0
IS_MAC=0
IS_OSS_SERIAL=0
while true; do
if [[ "$1" == "--virtualenv" ]]; then
IS_VIRTUALENV=1
elif [[ "$1" == "--gpu" ]]; then
IS_GPU=1
elif [[ "$1" == "--rocm" ]]; then
IS_ROCM=1
elif [[ "$1" == "--mac" ]]; then
IS_MAC=1
elif [[ "$1" == "--oss_serial" ]]; then
IS_OSS_SERIAL=1
fi
shift
if [[ -z "$1" ]]; then
break
fi
done
TF_GPU_COUNT=${TF_GPU_COUNT:-4}
if [[ ${IS_ROCM} == "1" ]]; then
TF_GPU_COUNT=$(lspci|grep 'controller'|grep 'AMD/ATI'|wc -l)
TF_TESTS_PER_GPU=1
N_TEST_JOBS=$(expr ${TF_GPU_COUNT} \* ${TF_TESTS_PER_GPU})
fi
# PIP tests should have a "different" path. Different than the one we place
# virtualenv, because we are deleting and recreating it here.
PIP_TEST_PREFIX=bazel_pip
PIP_TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
rm -rf $PIP_TEST_ROOT
mkdir -p $PIP_TEST_ROOT
ln -s $(pwd)/tensorflow ${PIP_TEST_ROOT}/tensorflow
# Do not run tests with "no_pip" tag. If running GPU tests, also do not run
# tests with no_pip_gpu tag.
PIP_TEST_FILTER_TAG="-no_pip,-no_oss,-oss_excluded,-benchmark-test"
if [[ ${IS_OSS_SERIAL} == "1" ]]; then
PIP_TEST_FILTER_TAG="$(echo "${PIP_TEST_FILTER_TAG}" | sed s/-no_oss//)"
PIP_TEST_FILTER_TAG="$(echo "${PIP_TEST_FILTER_TAG}" | sed s/-oss_excluded//)"
PIP_TEST_FILTER_TAG="${PIP_TEST_FILTER_TAG},oss_serial"
else
PIP_TEST_FILTER_TAG="${PIP_TEST_FILTER_TAG},-oss_serial"
fi
if [[ ${IS_GPU} == "1" ]] || [[ ${IS_ROCM} == "1" ]]; then
PIP_TEST_FILTER_TAG="-no_gpu,-no_pip_gpu,${PIP_TEST_FILTER_TAG}"
fi
if [[ ${IS_ROCM} == "1" ]]; then
PIP_TEST_FILTER_TAG="-no_rocm,-no_pip_rocm,${PIP_TEST_FILTER_TAG}"
fi
if [[ ${IS_MAC} == "1" ]]; then
# TODO(b/122370901): Fix nomac, no_mac inconsistency.
PIP_TEST_FILTER_TAG="-nomac,-no_mac,-mac_excluded,${PIP_TEST_FILTER_TAG}"
fi
# Bazel flags we need for all tests:
# define=no_tensorflow_py_deps=true, to skip all test dependencies.
# test_lang_filters=py only py tests for pip package testing
# TF_BUILD_APPEND_ARGUMENTS any user supplied args.
BAZEL_FLAGS="--define=no_tensorflow_py_deps=true --test_lang_filters=py \
--build_tests_only -k --test_tag_filters=${PIP_TEST_FILTER_TAG} \
${TF_BUILD_APPEND_ARGUMENTS} \
--test_output=errors"
if [[ ${IS_ROCM} == "1" ]]; then
BAZEL_FLAGS="${BAZEL_FLAGS} \
--test_timeout 600,900,2400,7200"
else
BAZEL_FLAGS="${BAZEL_FLAGS} \
--test_timeout 300,450,1200,3600"
fi
BAZEL_TEST_TARGETS="//${PIP_TEST_PREFIX}/tensorflow/python/..."
# Clean the bazel cache
bazel clean
# Run configure again, we might be using a different python path, due to
# virtualenv.
export TF_NEED_GCP=0
export TF_NEED_HDFS=0
# Obtain the path to Python binary
if [[ ${IS_VIRTUALENV} == "1" ]]; then
PYTHON_BIN_PATH="$(which python)"
else
source tools/python_bin_path.sh
# Assume: PYTHON_BIN_PATH is exported by the script above
fi
export TF_NEED_CUDA=$IS_GPU
export TF_NEED_ROCM=$IS_ROCM
yes "" | ${PYTHON_BIN_PATH} configure.py
# Figure out how many concurrent tests we can run and do run the tests.
BAZEL_PARALLEL_TEST_FLAGS=""
if [[ $IS_GPU == 1 ]] || [[ $IS_ROCM == 1 ]]; then
# Number of test threads is the number of GPU cards available.
if [[ $IS_MAC == 1 ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=1"
elif [[ $IS_ROCM == 1 ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=${N_TEST_JOBS} \
--test_env=TF_GPU_COUNT=$TF_GPU_COUNT \
--test_env=TF_TESTS_PER_GPU=$TF_TESTS_PER_GPU \
--test_sharding_strategy=disabled \
--run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute"
else
PAR_TEST_JOBS=$TF_GPU_COUNT
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=${TF_GPU_COUNT} \
--run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute"
fi
else
# Number of test threads is the number of physical CPUs.
if [[ $IS_MAC == 1 ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=$(sysctl -n hw.ncpu)"
else
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=$(grep -c ^processor /proc/cpuinfo)"
fi
fi
if [[ ${IS_OSS_SERIAL} == 1 ]]; then
BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=1"
fi
# Actually run the tests.
bazel test ${BAZEL_FLAGS} ${BAZEL_PARALLEL_TEST_FLAGS} -- \
${BAZEL_TEST_TARGETS}
+272
View File
@@ -0,0 +1,272 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
# This script tests the tutorials and examples in TensorFlow source code
# on pip installation. The tutorial scripts are copied from source to a
# separate directory for testing. The script performs some very basic quality
# checks on the results, such as thresholding final accuracy, verifying
# decrement of loss with training, and verifying the existence of saved
# checkpoints and summaries files.
#
# Usage: test_tutorials.sh [--virtualenv]
#
# If the flag --virtualenv is set, the script will use "python" as the Python
# binary path. Otherwise, it will use tools/python_bin_path.sh to determine
# the Python binary path.
#
# This script obeys the following environment variables (if exists):
# TUT_TESTS_DENYLIST: Force skipping of specified tutorial tests listed
# in TUT_TESTS below.
#
# List of all tutorial tests to run, separated by spaces
TUT_TESTS="mnist_with_summaries word2vec"
if [[ -z "${TUT_TESTS_DENYLIST}" ]]; then
TF_BUILD_TUT_TEST_DENYLIST=""
fi
echo ""
echo "=== Testing tutorials ==="
echo "TF_BUILD_TUT_TEST_DENYLIST = \"${TF_BUILD_TUT_TEST_DENYLIST}\""
# Timeout (in seconds) for each tutorial test
TIMEOUT=1800
TUT_TEST_ROOT=/tmp/tf_tutorial_test
TUT_TEST_DATA_DIR=/tmp/tf_tutorial_test_data
LOGS_DIR=pip_test/tutorial_tests/logs
# Current script directory
SCRIPT_DIR=$( cd ${0%/*} && pwd -P )
source "${SCRIPT_DIR}/builds_common.sh"
# Determine the binary path for "timeout"
TIMEOUT_BIN="timeout"
if [[ -z "$(which ${TIMEOUT_BIN})" ]]; then
TIMEOUT_BIN="gtimeout"
if [[ -z "$(which ${TIMEOUT_BIN})" ]]; then
die "Unable to locate binary path for timeout command"
fi
fi
echo "Binary path for timeout: \"$(which ${TIMEOUT_BIN})\""
# Avoid permission issues outside Docker containers
umask 000
mkdir -p "${LOGS_DIR}" || die "Failed to create logs directory"
mkdir -p "${TUT_TEST_ROOT}" || die "Failed to create test directory"
if [[ "$1" == "--virtualenv" ]]; then
PYTHON_BIN_PATH="$(which python)"
else
source tools/python_bin_path.sh
fi
if [[ -z "${PYTHON_BIN_PATH}" ]]; then
die "PYTHON_BIN_PATH was not provided. If this is not virtualenv, "\
"did you run configure?"
else
echo "Binary path for python: \"$PYTHON_BIN_PATH\""
fi
# Determine the TensorFlow installation path
# pushd/popd avoids importing TensorFlow from the source directory.
pushd /tmp > /dev/null
TF_INSTALL_PATH=$(dirname \
$("${PYTHON_BIN_PATH}" -c "import tensorflow as tf; print(tf.__file__)"))
popd > /dev/null
echo "Detected TensorFlow installation path: ${TF_INSTALL_PATH}"
TEST_DIR="pip_test/tutorials"
mkdir -p "${TEST_DIR}" || \
die "Failed to create test directory: ${TEST_DIR}"
# Copy folders required by mnist tutorials
mkdir -p "${TF_INSTALL_PATH}/examples/tutorials"
cp tensorflow/examples/tutorials/__init__.py \
"${TF_INSTALL_PATH}/examples/tutorials/"
cp -r tensorflow/examples/tutorials/mnist \
"${TF_INSTALL_PATH}/examples/tutorials/"
if [[ ! -d "${TF_INSTALL_PATH}/examples/tutorials/mnist" ]]; then
die "FAILED: Unable to copy directory required by MNIST tutorials: "\
"${TF_INSTALL_PATH}/examples/tutorials/mnist"
fi
# -----------------------------------------------------------
# mnist_softmax
test_mnist_softmax() {
LOG_FILE=$1
run_in_directory "${TEST_DIR}" "${LOG_FILE}" \
tensorflow/examples/tutorials/mnist/mnist_softmax.py \
--data_dir="${TUT_TEST_DATA_DIR}/mnist"
# Check final accuracy
FINAL_ACCURACY=$(tail -1 "${LOG_FILE}")
if [[ $(python -c "print(${FINAL_ACCURACY}>0.85)") != "True" ]] ||
[[ $(python -c "print(${FINAL_ACCURACY}<=1.00)") != "True" ]]; then
echo "mnist_softmax accuracy check FAILED: "\
"FINAL_ACCURACY = ${FINAL_ACCURACY}"
return 1
fi
}
# -----------------------------------------------------------
# mnist_with_summaries
test_mnist_with_summaries() {
LOG_FILE=$1
SUMMARIES_DIR="${TUT_TEST_ROOT}/summaries/mnist"
rm -rf "${SUMMARIES_DIR}"
# rm -rf "${TEST_DIR}/tensorflow"
if [[ $? != 0 ]]; then
echo "FAILED: unable to remove existing summaries directory: "\
"${SUMMARIES_DIR}"
return 1
fi
run_in_directory "${TEST_DIR}" "${LOG_FILE}" \
tensorflow/examples/tutorials/mnist/mnist_with_summaries.py \
--data_dir="${TUT_TEST_DATA_DIR}/mnist" --log_dir="${SUMMARIES_DIR}"
# Verify final accuracy
FINAL_ACCURACY=$(grep "Accuracy at step" "${LOG_FILE}" \
| tail -1 | awk '{print $NF}')
if [[ $(python -c "print(${FINAL_ACCURACY}>0.85)") != "True" ]] ||
[[ $(python -c "print(${FINAL_ACCURACY}<=1.00)") != "True" ]]; then
echo "mnist_with_summaries accuracy check FAILED: final accuracy = "\
"${FINAL_ACCURACY}"
return 1
fi
# Verify that the summaries file have been generated
if [[ ! -d "${SUMMARIES_DIR}" ]] ||
[[ -z $(ls "${SUMMARIES_DIR}") ]]; then
echo "FAILED: It appears that no summaries files were generated in "\
"${SUMMARIES_DIR}"
return 1
fi
}
# -----------------------------------------------------------
# cifar10_train
test_cifar10_train() {
LOG_FILE=$1
rm -rf "${TUT_TEST_ROOT}/cifar10_train"
if [[ $? != 0 ]]; then
echo "Unable to remove old cifar10_train directory"
return 1
fi
run_in_directory "${TEST_DIR}" "${LOG_FILE}" \
${TF_MODELS_DIR}/tutorials/image/cifar10/cifar10_train.py \
--data_dir="${TUT_TEST_DATA_DIR}/cifar10" --max_steps=50 \
--train_dir="${TUT_TEST_ROOT}/cifar10_train"
# Verify that final loss is less than initial loss
INIT_LOSS=$(grep -o "loss = [0-9\.]*" "${LOG_FILE}" | head -1 | \
awk '{print $NF}')
FINAL_LOSS=$(grep -o "loss = [0-9\.]*" "${LOG_FILE}" | tail -1 | \
awk '{print $NF}')
if [[ $(python -c "print(${FINAL_LOSS}<${INIT_LOSS})") != "True" ]] ||
[[ $(python -c "print(${INIT_LOSS}>=0)") != "True" ]] ||
[[ $(python -c "print(${FINAL_LOSS}>=0)") != "True" ]]; then
echo "cifar10_train loss check FAILED: "\
"FINAL_LOSS = ${FINAL_LOSS}; INIT_LOSS = ${INIT_LOSS}"
return 1
fi
return 0
}
# -----------------------------------------------------------
# word2vec_test
test_word2vec() {
LOG_FILE=$1
run_in_directory "${TEST_DIR}" "${LOG_FILE}" \
tensorflow/examples/tutorials/word2vec/word2vec_basic.py
}
# -----------------------------------------------------------
# ptb_word_lm
test_ptb_word_lm() {
LOG_FILE=$1
PTB_DATA_URL="http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz"
DATA_DIR="${TUT_TEST_DATA_DIR}/ptb"
if [[ ! -f "${DATA_DIR}/simple-examples/data/ptb.train.txt" ]] || \
[[ ! -f "${DATA_DIR}/simple-examples/data/ptb.valid.txt" ]] || \
[[ ! -f "${DATA_DIR}/simple-examples/data/ptb.test.txt" ]]; then
# Download and extract data
echo "Downloading and extracting PTB data from \"${PTB_DATA_URL}\" to "\
"${DATA_DIR}"
mkdir -p ${DATA_DIR}
pushd ${DATA_DIR} > /dev/null
curl --retry 5 --retry-delay 10 -O "${PTB_DATA_URL}" || \
die "Failed to download data file for ptb_world_lm tutorial from "\
"${PTB_DATA_URL}"
tar -xzf $(basename "${PTB_DATA_URL}")
rm -f $(basename "${PTB_DATA_URL}")
popd > /dev/null
if [[ ! -d "${DATA_DIR}/simple-examples/data" ]]; then
echo "FAILED to download and extract data for \"ptb_word_lm\""
return 1
fi
fi
run_in_directory "${TEST_DIR}" "${LOG_FILE}" \
"${TF_MODELS_DIR}/tutorials/rnn/ptb/ptb_word_lm.py" \
--data_path="${DATA_DIR}/simple-examples/data" --model test
if [[ $? != 0 ]]; then
echo "Tutorial test \"ptb_word_lm\" FAILED"
return 1
fi
# Extract epoch initial and final training perplexities
INIT_PERPL=$(grep -o "[0-9\.]* perplexity: [0-9\.]*" "${LOG_FILE}" | head -1 | awk '{print $NF}')
FINAL_PERPL=$(grep -o "[0-9\.]* perplexity: [0-9\.]*" "${LOG_FILE}" | tail -1 | awk '{print $NF}')
echo "INIT_PERPL=${INIT_PERPL}"
echo "FINAL_PERPL=${FINAL_PERPL}"
if [[ $(python -c "print(${FINAL_PERPL}<${INIT_PERPL})") != "True" ]] ||
[[ $(python -c "print(${INIT_PERPL}>=0)") != "True" ]] ||
[[ $(python -c "print(${FINAL_PERPL}>=0)") != "True" ]]; then
echo "ptb_word_lm perplexity check FAILED: "\
"FINAL_PERPL = ${FINAL_PERPL}; INIT_PERPL = ${INIT_PERPL}"
return 1
fi
}
# Run the tutorial tests
test_runner "tutorial test-on-install" \
"${TUT_TESTS}" "${TF_BUILD_TUT_TEST_DENYLIST}" "${LOGS_DIR}"
+258
View File
@@ -0,0 +1,258 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
# Test user-defined ops against installation of TensorFlow.
#
# Usage: test_user_ops.sh [--virtualenv] [--gpu]
#
# If the flag --virtualenv is set, the script will use "python" as the Python
# binary path. Otherwise, it will use tools/python_bin_path.sh to determine
# the Python binary path.
#
# The --gpu flag informs the script that this is a GPU build, so that the
# appropriate test denylists can be applied accordingly.
#
echo ""
echo "=== Testing user ops ==="
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds_common.sh"
# Process input arguments
IS_VIRTUALENV=0
IS_GPU=0
while true; do
if [[ "$1" == "--virtualenv" ]]; then
IS_VIRTUALENV=1
elif [[ "$1" == "--gpu" ]]; then
IS_GPU=1
fi
shift
if [[ -z "$1" ]]; then
break
fi
done
TMP_DIR=$(mktemp -d)
mkdir -p "${TMP_DIR}"
cleanup() {
rm -rf "${TMP_DIR}"
}
die() {
echo $@
cleanup
exit 1
}
# Obtain the path to Python binary
if [[ ${IS_VIRTUALENV} == "1" ]]; then
PYTHON_BIN_PATH="$(which python)"
else
source tools/python_bin_path.sh
# Assume: PYTHON_BIN_PATH is exported by the script above
fi
echo "PYTHON_BIN_PATH: ${PYTHON_BIN_PATH}"
pushd "${TMP_DIR}"
# Obtain compilation and linking flags
TF_CFLAGS=( $("${PYTHON_BIN_PATH}" \
-c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS=( $("${PYTHON_BIN_PATH}" \
-c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
if [[ -z "${TF_CFLAGS[*]}" || -z "${TF_LFLAGS[*]}" ]]; then
die "FAILED to determine TensorFlow compilation or linking flags"
else
echo "TensorFlow compile flags: ${TF_CFLAGS[*]}"
echo "TensorFlow link flags: ${TF_LFLAGS[*]}"
fi
# Check g++ availability
GPP_BIN="g++"
if [[ -z $(which "${GPP_BIN}") ]]; then
die "ERROR: ${GPP_BIN} not on path"
fi
echo ""
echo "g++ version:"
"${GPP_BIN}" -v
echo ""
IS_MAC=0
if [[ $(uname) == "Darwin" ]]; then
echo "Detected Mac OS X environment"
IS_MAC=1
fi
EXTRA_GPP_FLAGS=""
if [[ ${IS_MAC} == "1" ]]; then
# Extra flags required on Mac OS X, where dynamic_lookup is not the default
# behavior.
EXTRA_GPP_FLAGS="${EXTRA_GPP_FLAGS} -undefined dynamic_lookup"
fi
echo "Extra GPP flag: ${EXTRA_GPP_FLAGS}"
# Input to the user op
OP_INPUT="[42, 43, 44]"
if [[ ${IS_GPU} == "0" ]]; then
echo "Testing user ops in CPU environment"
# Expected output from user op
EXPECTED_OUTPUT="[42, 0, 0]"
# Locate the op kernel C++ file
OP_KERNEL_CC="${SCRIPT_DIR}/user_ops/zero_out_op_kernel_1.cc"
OP_KERNEL_CC=$(realpath "${OP_KERNEL_CC}")
if [[ ! -f "${OP_KERNEL_CC}" ]]; then
die "ERROR: Unable to find user-op kernel C++ file at: ${OP_KERNEL_CC}"
fi
# Copy the file to a non-TensorFlow source directory
cp "${OP_KERNEL_CC}" ./
# Compile the op kernel into an .so file
SRC_FILE=$(basename "${OP_KERNEL_CC}")
echo "Compiling user op C++ source file ${SRC_FILE}"
USER_OP_SO="zero_out.so"
"${GPP_BIN}" -std=c++11 ${EXTRA_GPP_FLAGS} \
-shared "${SRC_FILE}" -o "${USER_OP_SO}" \
-fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} || \
die "g++ compilation of ${SRC_FILE} FAILED"
else
echo "Testing user ops in GPU environment"
# Expected output from user op
EXPECTED_OUTPUT="[43, 44, 45]"
# Check nvcc availability
NVCC_BIN="/usr/local/cuda/bin/nvcc"
if [[ -z $(which "${NVCC_BIN}") ]]; then
die "ERROR: ${NVCC_BIN} not on path"
fi
echo ""
echo "nvcc version:"
"${NVCC_BIN}" --version
echo ""
OP_KERNEL_CU="${SCRIPT_DIR}/user_ops/cuda_op_kernel.cu.cc"
OP_KERNEL_CU=$(realpath "${OP_KERNEL_CU}")
if [[ ! -f "${OP_KERNEL_CU}" ]]; then
die "ERROR: Unable to find user-op kernel CUDA file at: ${OP_KERNEL_CU}"
fi
OP_KERNEL_CC="${SCRIPT_DIR}/user_ops/cuda_op_kernel.cc"
OP_KERNEL_CC=$(realpath "${OP_KERNEL_CC}")
if [[ ! -f "${OP_KERNEL_CC}" ]]; then
die "ERROR: Unable to find user-op kernel C++ file at: ${OP_KERNEL_CC}"
fi
# Copy the file to a non-TensorFlow source directory
cp "${OP_KERNEL_CU}" ./
cp "${OP_KERNEL_CC}" ./
OP_KERNEL_O=$(echo "${OP_KERNEL_CC}" | sed -e 's/\.cc/\.o/')
"${NVCC_BIN}" -std=c++11 \
-c -o "${OP_KERNEL_O}" "${OP_KERNEL_CU}" \
${TF_CFLAGS[@]} -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC || \
die "nvcc compilation of ${OP_KERNEL_CC} FAILED"
CUDA_LIB_DIR="/usr/local/cuda/lib64"
if [[ ! -d "${CUDA_LIB_DIR}" ]]; then
CUDA_LIB_DIR="/usr/local/cuda/lib"
fi
if [[ ! -d "${CUDA_LIB_DIR}" ]]; then
die "ERROR: Failed to find CUDA library directory at either of "
"/usr/local/cuda/lib and /usr/local/cuda/lib64"
fi
echo "Found CUDA library directory at: ${CUDA_LIB_DIR}"
echo ""
# USER_OP_SO=$(basename $(echo "${OP_KERNEL_CC}" | sed -e 's/\.cc/\.so/'))
USER_OP_SO="add_one.so"
"${GPP_BIN}" -std=c++11 ${EXTRA_GPP_FLAGS} \
-shared -o "${USER_OP_SO}" "${OP_KERNEL_CC}" \
"${OP_KERNEL_O}" ${TF_CFLAGS[@]} -L "${CUDA_LIB_DIR}" ${TF_LFLAGS[@]} \
-fPIC -lcudart || \
die "g++ compilation of ${OP_KERNEL_CC}" FAILED
fi
# Try running the op
USER_OP=$(echo "${USER_OP_SO}" | sed -e 's/\.so//')
echo "Invoking user op ${USER_OP} defined in file ${USER_OP_SO} "\
"via pip installation"
function run_op() {
local ORIG_OUTPUT=$1
local ADDITIONAL_LOG=$2
# Format OUTPUT for analysis
if [[ -z $(echo "${ORIG_OUTPUT}" | grep -o ',') ]]; then
if [[ ${IS_MAC} == "1" ]]; then
local OUTPUT=$(echo "${ORIG_OUTPUT}" | sed -E -e 's/[ \t]+/,/g')
else
local OUTPUT=$(echo "${ORIG_OUTPUT}" | sed -r -e 's/[ \t]+/,/g')
fi
else
local OUTPUT="${ORIG_OUTPUT}"
fi
local EQUALS_EXPECTED=$("${PYTHON_BIN_PATH}" -c "print(${OUTPUT} == ${EXPECTED_OUTPUT})")
if [[ "${EQUALS_EXPECTED}" != "True" ]]; then
local ERROR="FAILED: Output from user op (${OUTPUT}) does not match expected "\
"output ${EXPECTED_OUTPUT}"${ADDITIONAL_LOG}
die ${ERROR}
else
echo "Output from user op (${OUTPUT}) matches expected output"
fi
}
printf "\nTesting execution of user-defined op under graph mode:\n\n"
run_op "$("${PYTHON_BIN_PATH}" -c "import tensorflow as tf; print(tf.Session('').run(tf.load_op_library('./${USER_OP_SO}').${USER_OP}(${OP_INPUT})))")"
if [[ "${IS_GPU}" == "0" ]]; then
printf "\nTesting execution of user-defined op under eager mode:\n\n"
run_op "$("${PYTHON_BIN_PATH}" -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.load_op_library('./${USER_OP_SO}').${USER_OP}(${OP_INPUT}).numpy())")" " in eager mode"
else
printf "\nSKIPPING the testing of execution of user-defined GPU kernel under eager mode. See b/122972785.\n\n"
fi
popd
cleanup
echo ""
echo "SUCCESS: Testing of user ops PASSED"
@@ -0,0 +1,55 @@
/* Copyright 2015 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.
==============================================================================*/
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
using namespace tensorflow;
REGISTER_OP("AddOne")
.Input("input: int32")
.Output("output: int32")
.Doc(R"doc(
Adds 1 to all elements of the tensor.
output: A Tensor.
output = input + 1
)doc");
void AddOneKernelLauncher(const int* in, const int N, int* out);
class AddOneOp : public OpKernel {
public:
explicit AddOneOp(OpKernelConstruction* context) : OpKernel(context) {}
void Compute(OpKernelContext* context) override {
// Grab the input tensor
const Tensor& input_tensor = context->input(0);
auto input = input_tensor.flat<int32>();
// Create an output tensor
Tensor* output_tensor = NULL;
OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
&output_tensor));
auto output = output_tensor->template flat<int32>();
// Set all but the first element of the output tensor to 0.
const int N = input.size();
// Call the cuda kernel launcher
AddOneKernelLauncher(input.data(), N, output.data());
}
};
REGISTER_KERNEL_BUILDER(Name("AddOne").Device(DEVICE_GPU), AddOneOp);
@@ -0,0 +1,33 @@
/* Copyright 2015 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.
==============================================================================*/
#if GOOGLE_CUDA
#define EIGEN_USE_GPU
#include "unsupported/Eigen/CXX11/Tensor" // from @eigen_archive
#include "tensorflow/core/util/gpu_launch_config.h"
__global__ void AddOneKernel(const int* in, const int N, int* out) {
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N;
i += blockDim.x * gridDim.x) {
out[i] = in[i] + 1;
}
}
void AddOneKernelLauncher(const int* in, const int N, int* out) {
TF_CHECK_OK(::tensorflow::GpuLaunchKernel(AddOneKernel, 32, 256, 0, nullptr,
in, N, out));
}
#endif
@@ -0,0 +1,62 @@
/* Copyright 2015 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.
==============================================================================*/
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/shape_inference.h"
using namespace tensorflow;
REGISTER_OP("ZeroOut")
.Input("to_zero: int32")
.Output("zeroed: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
c->set_output(0, c->input(0));
return OkStatus();
})
.Doc(R"doc(
Zeros out all but the first value of a Tensor.
zeroed: A Tensor whose first value is identical to `to_zero`, and 0
otherwise.
)doc");
class ZeroOutOp : public OpKernel {
public:
explicit ZeroOutOp(OpKernelConstruction* context) : OpKernel(context) {}
void Compute(OpKernelContext* context) override {
// Grab the input tensor
const Tensor& input_tensor = context->input(0);
auto input = input_tensor.flat<int32>();
// Create an output tensor
Tensor* output_tensor = NULL;
OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(),
&output_tensor));
auto output = output_tensor->template flat<int32>();
// Set all but the first element of the output tensor to 0.
const int N = input.size();
for (int i = 1; i < N; i++) {
output(i) = 0;
}
// Preserve the first input value.
if (N > 0) output(0) = input(0);
}
};
REGISTER_KERNEL_BUILDER(Name("ZeroOut").Device(DEVICE_CPU), ZeroOutOp);
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# ==============================================================================
# This script is a wrapper creating the same user inside container as the one
# running the ci_build.sh outside the container. It also set the home directory
# for the user inside container to match the same absolute path as the workspace
# outside of container.
# We do this so that the bazel running inside container generate symbolic links
# and user permissions which makes sense outside of container.
# Do not run this manually. It does not make sense. It is intended to be called
# by ci_build.sh only.
set -e
COMMAND=("$@")
if [[ $(awk -F= '/^NAME/{print $2}' /etc/os-release) == *"CentOS"* ]]; then
${COMMAND[@]}
else
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
if [ -n "${CI_BUILD_USER_FORCE_BADNAME}" ]; then
ADDUSER_OPTS="--force-badname"
fi
apt-get install sudo
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 [[ "${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
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
@@ -0,0 +1,48 @@
# Copyright 2025 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.
# ==============================================================================
"""Calculates full TensorFlow version."""
import argparse
import time
def parse_args():
"""Arguments parser."""
parser = argparse.ArgumentParser(
description="Helper for TensorFlow version calculation",
fromfile_prefix_chars="@",
)
parser.add_argument(
"--wheel-type",
required=True,
choices=["nightly", "release"],
help="Type of the wheel",
)
parser.add_argument("--wheel-version", required=True, help="Wheel version")
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
tensorflow_version_suffix = ""
if args.wheel_type == "nightly":
tensorflow_version_suffix = "-dev{}".format(time.strftime("%Y%m%d"))
print(
'"{wheel_version}{tensorflow_version_suffix}"'.format(
wheel_version=args.wheel_version,
tensorflow_version_suffix=tensorflow_version_suffix,
)
)
+181
View File
@@ -0,0 +1,181 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# ==============================================================================
#
# Usage: ci_build.sh <CONTAINER_TYPE> [--dockerfile <DOCKERFILE_PATH>]
# <COMMAND>
#
# CONTAINER_TYPE: Type of the docker container used the run the build:
# e.g., (cpu | gpu | rocm | android | tensorboard)
#
# DOCKERFILE_PATH: (Optional) Path to the Dockerfile used for docker build.
# If this optional value is not supplied (via the
# --dockerfile flag), default Dockerfiles in the same
# directory as this script will be used.
#
# COMMAND: Command to be executed in the docker container, e.g.,
# tensorflow/tools/ci_build/builds/pip.sh gpu -c opt --config=cuda
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/builds/builds_common.sh"
# Get the command line arguments.
CONTAINER_TYPE=$( echo "$1" | tr '[:upper:]' '[:lower:]' )
shift 1
# Dockerfile to be used in docker build
DOCKERFILE_PATH="${SCRIPT_DIR}/Dockerfile.${CONTAINER_TYPE}"
DOCKER_CONTEXT_PATH="${SCRIPT_DIR}"
if [[ "$1" == "--dockerfile" ]]; then
DOCKERFILE_PATH="$2"
DOCKER_CONTEXT_PATH=$(dirname "${DOCKERFILE_PATH}")
echo "Using custom Dockerfile path: ${DOCKERFILE_PATH}"
echo "Using custom docker build context path: ${DOCKER_CONTEXT_PATH}"
shift 2
fi
if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
die "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
fi
COMMAND=("$@")
# Validate command line arguments.
if [ "$#" -lt 1 ] || [ ! -e "${SCRIPT_DIR}/Dockerfile.${CONTAINER_TYPE}" ]; then
supported_container_types=$( ls -1 ${SCRIPT_DIR}/Dockerfile.* | \
sed -n 's/.*Dockerfile\.\([^\/]*\)/\1/p' | tr '\n' ' ' )
>&2 echo "Usage: $(basename $0) CONTAINER_TYPE COMMAND"
>&2 echo " CONTAINER_TYPE can be one of [ ${supported_container_types}]"
>&2 echo " COMMAND is a command (with arguments) to run inside"
>&2 echo " the container."
>&2 echo ""
>&2 echo "Example (run all tests on CPU):"
>&2 echo "$0 CPU bazel test //tensorflow/..."
exit 1
fi
# Optional arguments - environment variables. For example:
# CI_DOCKER_EXTRA_PARAMS='-it --rm' CI_COMMAND_PREFIX='' tensorflow/tools/ci_build/ci_build.sh CPU /bin/bash
CI_TENSORFLOW_SUBMODULE_PATH="${CI_TENSORFLOW_SUBMODULE_PATH:-.}"
CI_COMMAND_PREFIX=("${CI_COMMAND_PREFIX[@]:-${CI_TENSORFLOW_SUBMODULE_PATH}/tensorflow/tools/ci_build/builds/with_the_same_user "\
"${CI_TENSORFLOW_SUBMODULE_PATH}/tensorflow/tools/ci_build/builds/configured ${CONTAINER_TYPE}}")
# cmake (CPU) and micro builds do not require configuration.
if [[ "${CONTAINER_TYPE}" == "cmake" ]] || [[ "${CONTAINER_TYPE}" == "micro" ]]; then
CI_COMMAND_PREFIX=("")
fi
# Use nvidia-docker if the container is GPU.
if [[ "${CONTAINER_TYPE}" == gpu* ]]; then
DOCKER_BINARY="nvidia-docker"
if [[ -z `which ${DOCKER_BINARY}` ]]; then
# No nvidia-docker; fall back on docker to allow build operations that
# require CUDA but don't require a GPU to run.
echo "Warning: nvidia-docker not found in PATH. Falling back on 'docker'."
DOCKER_BINARY="docker"
fi
else
DOCKER_BINARY="docker"
fi
# Helper function to traverse directories up until given file is found.
function upsearch () {
test / == "$PWD" && return || \
test -e "$1" && echo "$PWD" && return || \
cd .. && upsearch "$1"
}
# Set up WORKSPACE and BUILD_TAG. Jenkins will set them for you or we pick
# reasonable defaults if you run it outside of Jenkins.
WORKSPACE="${WORKSPACE:-$(upsearch WORKSPACE)}"
BUILD_TAG="${BUILD_TAG:-tf_ci}"
# Add extra params for cuda devices and libraries for GPU container.
# And clear them if we are not building for GPU.
if [[ "${CONTAINER_TYPE}" != gpu* ]]; then
GPU_EXTRA_PARAMS=""
fi
# Add extra params for rocm devices and libraries for ROCm container.
if [[ "${CONTAINER_TYPE}" == "rocm" ]]; then
ROCM_EXTRA_PARAMS="--device=/dev/kfd --device=/dev/dri --group-add video \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined --shm-size 16G"
else
ROCM_EXTRA_PARAMS=""
fi
# Determine the docker image name
DOCKER_IMG_NAME="${BUILD_TAG}.${CONTAINER_TYPE}"
# Under Jenkins matrix build, the build tag may contain characters such as
# commas (,) and equal signs (=), which are not valid inside docker image names.
DOCKER_IMG_NAME=$(echo "${DOCKER_IMG_NAME}" | sed -e 's/=/_/g' -e 's/,/-/g')
# Convert to all lower-case, as per requirement of Docker image names
DOCKER_IMG_NAME=$(echo "${DOCKER_IMG_NAME}" | tr '[:upper:]' '[:lower:]')
# Print arguments.
echo "WORKSPACE: ${WORKSPACE}"
echo "CI_DOCKER_BUILD_EXTRA_PARAMS: ${CI_DOCKER_BUILD_EXTRA_PARAMS[*]}"
echo "CI_DOCKER_EXTRA_PARAMS: ${CI_DOCKER_EXTRA_PARAMS[*]}"
echo "COMMAND: ${COMMAND[*]}"
echo "CI_COMMAND_PREFIX: ${CI_COMMAND_PREFIX[*]}"
echo "CONTAINER_TYPE: ${CONTAINER_TYPE}"
echo "BUILD_TAG: ${BUILD_TAG}"
echo " (docker container name will be ${DOCKER_IMG_NAME})"
echo ""
# Build the docker container.
echo "Building container (${DOCKER_IMG_NAME})..."
docker build -t ${DOCKER_IMG_NAME} ${CI_DOCKER_BUILD_EXTRA_PARAMS[@]} \
-f "${DOCKERFILE_PATH}" "${DOCKER_CONTEXT_PATH}"
# Check docker build status
if [[ $? != "0" ]]; then
die "ERROR: docker build failed. Dockerfile is at ${DOCKERFILE_PATH}"
fi
# If caller wants the with_the_same_user script to allow bad usernames,
# pass the var to the docker environment
if [ -n "${CI_BUILD_USER_FORCE_BADNAME}" ]; then
CI_BUILD_USER_FORCE_BADNAME_ENV="-e CI_BUILD_USER_FORCE_BADNAME=yes"
fi
# Run the command inside the container.
echo "Running '${COMMAND[*]}' inside ${DOCKER_IMG_NAME}..."
mkdir -p ${WORKSPACE}/bazel-ci_build-cache
# By default we cleanup - remove the container once it finish running (--rm)
# and share the PID namespace (--pid=host) so the process inside does not have
# pid 1 and SIGKILL is propagated to the process inside (jenkins can kill it).
${DOCKER_BINARY} run --rm --name ${DOCKER_IMG_NAME} --pid=host \
-v ${WORKSPACE}/bazel-ci_build-cache:${WORKSPACE}/bazel-ci_build-cache \
-e "CI_BUILD_HOME=${WORKSPACE}/bazel-ci_build-cache" \
-e "CI_BUILD_USER=$(id -u -n)" \
-e "CI_BUILD_UID=$(id -u)" \
-e "CI_BUILD_GROUP=$(id -g -n)" \
-e "CI_BUILD_GID=$(id -g)" \
-e "CI_TENSORFLOW_SUBMODULE_PATH=${CI_TENSORFLOW_SUBMODULE_PATH}" \
${CI_BUILD_USER_FORCE_BADNAME_ENV} \
-v ${WORKSPACE}:/workspace \
-w /workspace \
${GPU_EXTRA_PARAMS} \
${ROCM_EXTRA_PARAMS} \
${CI_DOCKER_EXTRA_PARAMS[@]} \
"${DOCKER_IMG_NAME}" \
${CI_COMMAND_PREFIX[@]} \
${COMMAND[@]}
+23
View File
@@ -0,0 +1,23 @@
# Copyright 2026 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.
# ==============================================================================
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-f', '$_DOCKERFILE', '-t', 'gcr.io/$PROJECT_ID/$_IMAGE_NAME', '.']
substitutions:
_DOCKERFILE: ''
_IMAGE_NAME: ''
images:
- 'gcr.io/$PROJECT_ID/$_IMAGE_NAME'
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright 2017 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.
# ==============================================================================
# please run this at root directory of tensorflow
success=1
for i in `grep -onI https://www.tensorflow.org/code/\[a-zA-Z0-9/._-\]\* -r tensorflow`
do
filename=`echo $i|awk -F: '{print $1}'`
linenumber=`echo $i|awk -F: '{print $2}'`
target=`echo $i|awk -F: '{print $4}'|tail -c +27`
# skip files in tensorflow/models
if [[ $target == tensorflow_models/* ]] ; then
continue
fi
if [ ! -f $target ] && [ ! -d $target ]; then
success=0
echo Broken link $target at line $linenumber of file $filename
fi
done
if [ $success == 0 ]; then
echo Code link check fails.
exit 1
fi
echo Code link check success.
+134
View File
@@ -0,0 +1,134 @@
#!/usr/bin/python
# Copyright 2017 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.
# ==============================================================================
#
# Automatically copy TensorFlow binaries
#
# Usage:
# ./tensorflow/tools/ci_build/copy_binary.py --filename
# tf_nightly/tf_nightly_gpu-1.4.0.dev20170914-cp35-cp35m-manylinux1_x86_64.whl
# --new_py_ver 36
#
"""Copy binaries of TensorFlow for different python versions."""
# pylint: disable=superfluous-parens
import argparse
import os
import re
import shutil
import tempfile
import zipfile
TF_NIGHTLY_REGEX = (r"(.+)(tf_nightly.*)-(\d\.[\d]{1,2}"
r"\.\d.dev[\d]{0,8})-(.+)\.whl")
BINARY_STRING_TEMPLATE = "%s-%s-%s.whl"
def check_existence(filename):
"""Check the existence of file or dir."""
if not os.path.exists(filename):
raise RuntimeError("%s not found." % filename)
def copy_binary(directory, origin_tag, new_tag, version, package):
"""Rename and copy binaries for different python versions.
Args:
directory: string of directory
origin_tag: str of the old python version tag
new_tag: str of the new tag
version: the version of the package
package: str, name of the package
"""
print("Rename and copy binaries with %s to %s." % (origin_tag, new_tag))
origin_binary = BINARY_STRING_TEMPLATE % (package, version, origin_tag)
new_binary = BINARY_STRING_TEMPLATE % (package, version, new_tag)
zip_ref = zipfile.ZipFile(os.path.join(directory, origin_binary), "r")
try:
tmpdir = tempfile.mkdtemp()
os.chdir(tmpdir)
zip_ref.extractall()
zip_ref.close()
old_py_ver = re.search(r"(cp\d\d-cp\d\d)", origin_tag).group(1)
new_py_ver = re.search(r"(cp\d\d-cp\d\d)", new_tag).group(1)
wheel_file = os.path.join(
tmpdir, "%s-%s.dist-info" % (package, version), "WHEEL")
with open(wheel_file, "r") as f:
content = f.read()
with open(wheel_file, "w") as f:
f.write(content.replace(old_py_ver, new_py_ver))
zout = zipfile.ZipFile(directory + new_binary, "w", zipfile.ZIP_DEFLATED)
zip_these_files = [
"%s-%s.dist-info" % (package, version),
"%s-%s.data" % (package, version),
"tensorflow",
"tensorflow_core",
]
for dirname in zip_these_files:
for root, _, files in os.walk(dirname):
for filename in files:
zout.write(os.path.join(root, filename))
zout.close()
finally:
shutil.rmtree(tmpdir)
def main():
"""This script copies binaries.
Requirements:
filename: The path to the whl file
AND
new_py_ver: Create a nightly tag with current date
Raises:
RuntimeError: If the whl file was not found
"""
parser = argparse.ArgumentParser(description="Cherry picking automation.")
# Arg information
parser.add_argument(
"--filename", help="path to whl file we are copying", required=True)
parser.add_argument(
"--new_py_ver", help="two digit py version eg. 27 or 33", required=True)
args = parser.parse_args()
# Argument checking
args.filename = os.path.abspath(args.filename)
check_existence(args.filename)
regex_groups = re.search(TF_NIGHTLY_REGEX, args.filename)
directory = regex_groups.group(1)
package = regex_groups.group(2)
version = regex_groups.group(3)
origin_tag = regex_groups.group(4)
old_py_ver = re.search(r"(cp\d\d)", origin_tag).group(1)
# Create new tags
new_tag = origin_tag.replace(old_py_ver, "cp" + args.new_py_ver)
# Copy the binary with the info we have
copy_binary(directory, origin_tag, new_tag, version, package)
if __name__ == "__main__":
main()
+13
View File
@@ -0,0 +1,13 @@
load("@rules_shell//shell:sh_library.bzl", "sh_library")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)
sh_library(
name = "ctpu",
srcs = ["ctpu.sh"],
deps = [],
)
+133
View File
@@ -0,0 +1,133 @@
#!/bin/bash
# Copyright 2019 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.
# ==============================================================================
# Reusable functions for using CTPU in a Kokoro build.
# These functions are unit tested in ctpu_test.sh.
# Installs the Cloud TPU CLI to the current directory.
# Pass pip command as first arg, ex: install_ctpu pip3.7
function install_ctpu {
PIP_CMD="${1:-pip}"
# TPUClusterResolver has a runtime dependency cloud-tpu-client when
# resolving a Cloud TPU. It's very likely we want this installed if we're
# using CTPU.
# Replace cloud-tpu-client with google-api-python-client oauth2client to test
# the client at head.
"${PIP_CMD}" install --user --upgrade --ignore-installed cloud-tpu-client
wget -nv "https://dl.google.com/cloud_tpu/ctpu/latest/linux/ctpu"
chmod a+x ctpu
}
# Starts a Cloud TPU, storing metadata into artifacts dir for export.
#
# This function supports overriding the default parameters, using optional
# single-letter flags.
#
# Usage:
# ctpu_up -n [tpu name] -z [zone] -s [tpu size] -v [tf-version] \
# -p [cloud project] -g [gcp-network]
function ctpu_up {
local OPTIND o # Used for flag parsing
# Generate a unique random name for TPU, as we might be running multiple builds in parallel.
local name="kokoro-tpu-${RANDOM}"
local zone="us-central1-c"
local size="v2-8"
local version="nightly"
local project # Project automatically detected from environment.
local gcp_network # Network needed only if project default is Legacy.
# Override any of the above params from flags.
while getopts ":n:z:p:s:v:g:" o; do
case "${o}" in
n)
name="${OPTARG}"
;;
z)
zone="${OPTARG}"
;;
p)
project="${OPTARG}"
;;
s)
size="${OPTARG}"
;;
v)
version="${OPTARG}"
;;
g)
gcp_network="${OPTARG}"
;;
*)
echo "Unexpected parameter for ctpu_up: ${o}"
exit 1
esac
done
shift $((OPTIND-1))
export TPU_NAME="${name}"
export TPU_ZONE="${zone}"
# Store name and zone into artifacts dir so cleanup job has access.
echo "${TPU_NAME}" > "${TF_ARTIFACTS_DIR}/tpu_name"
echo "${TPU_ZONE}" > "${TF_ARTIFACTS_DIR}/tpu_zone"
local args=(
"--zone=${zone}"
"--tf-version=${version}"
"--name=${name}"
"--tpu-size=${size}"
"--tpu-only"
"-noconf"
)
# "-v" is a bash 4.2 builtin for checking that a variable is set.
if [[ -v gcp_network ]]; then
args+=("--gcp-network=${gcp_network}")
fi
if [[ -v project ]]; then
args+=("--project=${project}")
export TPU_PROJECT="${project}"
echo "${project}" > "${TF_ARTIFACTS_DIR}/tpu_project"
fi
./ctpu up "${args[@]}"
}
# Delete the Cloud TPU specified by the metadata in the gfile directory.
function ctpu_delete {
export TPU_NAME="$(cat "${TF_GFILE_DIR}/tpu_name")"
export TPU_ZONE="$(cat "${TF_GFILE_DIR}/tpu_zone")"
TPU_PROJECT_FILE="${TF_GFILE_DIR}/tpu_project"
if [ -f "${TPU_PROJECT_FILE}" ]; then
export TPU_PROJECT="$(cat ${TPU_PROJECT_FILE})"
else
export TPU_PROJECT="tensorflow-testing"
fi
# Retry due to rare race condition where TPU creation hasn't propagated by
# the time we try to delete it.
for i in 1 2 3; do
./ctpu delete \
--project=${TPU_PROJECT} \
--zone="${TPU_ZONE}" \
--name="${TPU_NAME}" \
--tpu-only \
-noconf && return 0 || sleep 60
done
return 1
}
@@ -0,0 +1,26 @@
diff --git a/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl b/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
index 282ba08cda..93713a66dd 100644
--- a/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
+++ b/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
@@ -1311,7 +1311,7 @@ def _impl(ctx):
fastbuild_feature,
dbg_feature,
supports_dynamic_linker_feature,
- supports_pic_feature,
+ supports_pic_feature, feature(name='hack', enabled=True, flag_sets = [ flag_set(actions = [ ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, ACTION_NAMES.cpp_link_executable, ACTION_NAMES.cpp_link_dynamic_library, ACTION_NAMES.cpp_link_nodeps_dynamic_library, ], flag_groups = [ flag_group( flags = ["--sysroot=/dt7"] ) ]) ]),
]
elif (ctx.attr.cpu == "darwin"):
features = [
diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl
index cf63adcbaa..c0718a9762 100644
--- a/third_party/gpus/cuda_configure.bzl
+++ b/third_party/gpus/cuda_configure.bzl
@@ -282,7 +282,7 @@ def _get_cxx_inc_directories_impl(repository_ctx, cc, lang_is_cpp):
lang = "c++"
else:
lang = "c"
- result = repository_ctx.execute([cc, "-E", "-x" + lang, "-", "-v"])
+ result = repository_ctx.execute([cc, "-E", "-x" + lang, "-", "-v", "--sysroot=/dt7", "-no-canonical-prefixes"])
index1 = result.stderr.find(_INC_DIR_MARKER_BEGIN)
if index1 == -1:
return []
+191
View File
@@ -0,0 +1,191 @@
#!/bin/bash -eu
# Copyright 2016 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.
# ==============================================================================
#
# Builds a devtoolset cross-compiler targeting manylinux 2010 (glibc 2.12 /
# libstdc++ 4.4) or manylinux2014 (glibc 2.17 / libstdc++ 4.8).
VERSION="$1"
TARGET="$2"
case "${VERSION}" in
devtoolset-7)
LIBSTDCXX_VERSION="6.0.24"
LIBSTDCXX_ABI="gcc4-compatible"
;;
devtoolset-9)
LIBSTDCXX_VERSION="6.0.28"
LIBSTDCXX_ABI="new"
;;
*)
echo "Usage: $0 {devtoolset-7|devtoolset-9} <target-directory>"
echo "Use 'devtoolset-7' to build a manylinux2010 compatible toolchain or 'devtoolset-9' to build a manylinux2014 compatible toolchain"
exit 1
;;
esac
mkdir -p "${TARGET}"
# Download glibc's shared and development libraries based on the value of the
# `VERSION` parameter.
# Note: 'Templatizing' this and the other conditional branches would require
# defining several variables (version, os, path) making it difficult to maintain
# and extend for future modifications.
case "${VERSION}" in
devtoolset-7)
# Download binary glibc 2.12 shared library release.
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.12.1-0ubuntu6_amd64.deb" && \
unar "libc6_2.12.1-0ubuntu6_amd64.deb" && \
tar -C "${TARGET}" -xvzf "libc6_2.12.1-0ubuntu6_amd64/data.tar.gz" && \
rm -rf "libc6_2.12.1-0ubuntu6_amd64.deb" "libc6_2.12.1-0ubuntu6_amd64"
# Download binary glibc 2.12 development library release.
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6-dev_2.12.1-0ubuntu6_amd64.deb" && \
unar "libc6-dev_2.12.1-0ubuntu6_amd64.deb" && \
tar -C "${TARGET}" -xvzf "libc6-dev_2.12.1-0ubuntu6_amd64/data.tar.gz" && \
rm -rf "libc6-dev_2.12.1-0ubuntu6_amd64.deb" "libc6-dev_2.12.1-0ubuntu6_amd64"
;;
devtoolset-9)
# Download binary glibc 2.17 shared library release.
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.17-0ubuntu5.1_amd64.deb" && \
unar "libc6_2.17-0ubuntu5.1_amd64.deb" && \
tar -C "${TARGET}" -xvzf "libc6_2.17-0ubuntu5.1_amd64/data.tar.gz" && \
rm -rf "libc6_2.17-0ubuntu5.1_amd64.deb" "libc6_2.17-0ubuntu5.1_amd64"
# Download binary glibc 2.17 development library release.
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6-dev_2.17-0ubuntu5.1_amd64.deb" && \
unar "libc6-dev_2.17-0ubuntu5.1_amd64.deb" && \
tar -C "${TARGET}" -xvzf "libc6-dev_2.17-0ubuntu5.1_amd64/data.tar.gz" && \
rm -rf "libc6-dev_2.17-0ubuntu5.1_amd64.deb" "libc6-dev_2.17-0ubuntu5.1_amd64"
;;
esac
# Put the current kernel headers from ubuntu in place.
ln -s "/usr/include/linux" "/${TARGET}/usr/include/linux"
ln -s "/usr/include/asm-generic" "/${TARGET}/usr/include/asm-generic"
ln -s "/usr/include/x86_64-linux-gnu/asm" "/${TARGET}/usr/include/asm"
# Symlinks in the binary distribution are set up for installation in /usr, we
# need to fix up all the links to stay within /${TARGET}.
/fixlinks.sh "/${TARGET}"
# Patch to allow non-glibc 2.12 compatible builds to work.
sed -i '54i#define TCP_USER_TIMEOUT 18' "/${TARGET}/usr/include/netinet/tcp.h"
# Download specific version of libstdc++ shared library based on the value of
# the `VERSION` parameter
case "${VERSION}" in
devtoolset-7)
# Download binary libstdc++ 4.4 release we are going to link against.
# We only need the shared library, as we're going to develop against the
# libstdc++ provided by devtoolset.
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/g/gcc-4.4/libstdc++6_4.4.3-4ubuntu5_amd64.deb" && \
unar "libstdc++6_4.4.3-4ubuntu5_amd64.deb" && \
tar -C "/${TARGET}" -xvzf "libstdc++6_4.4.3-4ubuntu5_amd64/data.tar.gz" "./usr/lib/libstdc++.so.6.0.13" && \
rm -rf "libstdc++6_4.4.3-4ubuntu5_amd64.deb" "libstdc++6_4.4.3-4ubuntu5_amd64"
;;
devtoolset-9)
# Download binary libstdc++ 4.8 shared library release
wget "http://old-releases.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libstdc++6_4.8.1-10ubuntu8_amd64.deb" && \
unar "libstdc++6_4.8.1-10ubuntu8_amd64.deb" && \
tar -C "/${TARGET}" -xvzf "libstdc++6_4.8.1-10ubuntu8_amd64/data.tar.gz" "./usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18" && \
rm -rf "libstdc++6_4.8.1-10ubuntu8_amd64.deb" "libstdc++6_4.8.1-10ubuntu8_amd64"
;;
esac
mkdir -p "${TARGET}-src"
cd "${TARGET}-src"
# Build a devtoolset cross-compiler based on our glibc 2.12/glibc 2.17 sysroot setup.
case "${VERSION}" in
devtoolset-7)
wget "http://vault.centos.org/centos/6/sclo/Source/rh/devtoolset-7/devtoolset-7-gcc-7.3.1-5.15.el6.src.rpm"
rpm2cpio "devtoolset-7-gcc-7.3.1-5.15.el6.src.rpm" |cpio -idmv
tar -xvjf "gcc-7.3.1-20180303.tar.bz2" --strip 1
;;
devtoolset-9)
wget "https://vault.centos.org/centos/7/sclo/Source/rh/devtoolset-9-gcc-9.3.1-2.2.el7.src.rpm"
rpm2cpio "devtoolset-9-gcc-9.3.1-2.2.el7.src.rpm" |cpio -idmv
tar -xvf "gcc-9.3.1-20200408.tar.xz" --strip 1
;;
esac
# Apply the devtoolset patches to gcc.
/rpm-patch.sh "gcc.spec"
./contrib/download_prerequisites
mkdir -p "${TARGET}-build"
cd "${TARGET}-build"
"${TARGET}-src/configure" \
--prefix=/"${TARGET}/usr" \
--with-sysroot="/${TARGET}" \
--disable-bootstrap \
--disable-libmpx \
--disable-libsanitizer \
--disable-libunwind-exceptions \
--disable-libunwind-exceptions \
--disable-lto \
--disable-multilib \
--enable-__cxa_atexit \
--enable-gnu-indirect-function \
--enable-gnu-unique-object \
--enable-initfini-array \
--enable-languages="c,c++" \
--enable-linker-build-id \
--enable-plugin \
--enable-shared \
--enable-threads=posix \
--with-default-libstdcxx-abi=${LIBSTDCXX_ABI} \
--with-gcc-major-version-only \
--with-linker-hash-style="gnu" \
--with-tune="generic" \
&& \
make -j 42 && \
make install
# Create the devtoolset libstdc++ linkerscript that links dynamically against
# the system libstdc++ 4.4 and provides all other symbols statically.
case "${VERSION}" in
devtoolset-7)
mv "/${TARGET}/usr/lib/libstdc++.so.${LIBSTDCXX_VERSION}" \
"/${TARGET}/usr/lib/libstdc++.so.${LIBSTDCXX_VERSION}.backup"
echo -e "OUTPUT_FORMAT(elf64-x86-64)\nINPUT ( libstdc++.so.6.0.13 -lstdc++_nonshared44 )" \
> "/${TARGET}/usr/lib/libstdc++.so.${LIBSTDCXX_VERSION}"
cp "./x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++_nonshared44.a" \
"/${TARGET}/usr/lib"
;;
devtoolset-9)
# Note that the installation path for libstdc++ here is /${TARGET}/usr/lib64/
mv "/${TARGET}/usr/lib64/libstdc++.so.${LIBSTDCXX_VERSION}" \
"/${TARGET}/usr/lib64/libstdc++.so.${LIBSTDCXX_VERSION}.backup"
echo -e "OUTPUT_FORMAT(elf64-x86-64)\nINPUT ( libstdc++.so.6.0.18 -lstdc++_nonshared44 )" \
> "/${TARGET}/usr/lib64/libstdc++.so.${LIBSTDCXX_VERSION}"
cp "./x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++_nonshared44.a" \
"/${TARGET}/usr/lib64"
;;
esac
# Link in architecture specific includes from the system; note that we cannot
# link in the whole x86_64-linux-gnu folder, as otherwise we're overlaying
# system gcc paths that we do not want to find.
# TODO(klimek): Automate linking in all non-gcc / non-kernel include
# directories.
mkdir -p "/${TARGET}/usr/include/x86_64-linux-gnu"
PYTHON_VERSIONS=("python3.7m" "python3.8" "python3.9" "python3.10" "python3.11")
for v in "${PYTHON_VERSIONS[@]}"; do
ln -s "/usr/local/include/${v}" "/${TARGET}/usr/include/x86_64-linux-gnu/${v}"
done
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2016 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.
# ==============================================================================
#
# Re-direct all links in $1 that point to /lib... to point to $1/lib... instead.
BASE="$1"
find "${BASE}" -type l | \
while read l ; do
if [[ "$(readlink "$l")" == /lib* ]]; then
ORIG="$(readlink "$l")";
rm "$l";
ln -s "${BASE}${ORIG}" "$l"
fi
done
@@ -0,0 +1,34 @@
diff --git a/tensorflow/tools/pip_package/build_pip_package.sh b/tensorflow/tools/pip_package/build_pip_package.sh
index 305033cd44..d2c43dc7ab 100755
--- a/tensorflow/tools/pip_package/build_pip_package.sh
+++ b/tensorflow/tools/pip_package/build_pip_package.sh
@@ -135,6 +135,7 @@ function prepare_src() {
cp tensorflow/tools/pip_package/MANIFEST.in ${TMPDIR}
cp tensorflow/tools/pip_package/README ${TMPDIR}
cp tensorflow/tools/pip_package/setup.py ${TMPDIR}
+ touch ${TMPDIR}/stub.cc
rm -f ${TMPDIR}/tensorflow/libtensorflow_framework.so
rm -f ${TMPDIR}/tensorflow/libtensorflow_framework.so.[0-9].*
diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py
index c36a2a0fa8..6ed096aafc 100644
--- a/tensorflow/tools/pip_package/setup.py
+++ b/tensorflow/tools/pip_package/setup.py
@@ -34,7 +34,7 @@ import os
import re
import sys
-from setuptools import Command
+from setuptools import Command, Extension
from setuptools import find_packages
from setuptools import setup
from setuptools.command.install import install as InstallCommandBase
@@ -269,6 +269,7 @@ setup(
EXTENSION_NAME,
] + matches,
},
+ ext_modules=[Extension('_foo', ['stub.cc'])],
zip_safe=False,
distclass=BinaryDistribution,
cmdclass={
)
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash -eu
# Copyright 2016 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.
# ==============================================================================
#
# Given an RPM spec file $1, apply its patches.
SPEC="$1"
grep '%patch' "${SPEC}" |while read cmd ; do
N=$(echo "${cmd}" |sed 's,%patch\([0-9]\+\).*,\1,')
file=$(grep "Patch$N:" "${SPEC}" |sed 's,.*: ,,')
parg=$(echo "${cmd}" |sed 's,.*\(-p[0-9]\).*,\1,')
if [[ ! "${file}" =~ doxygen && "${cmd}" != \#* ]]; then
echo "patch ${parg} -s < ${file}"
patch ${parg} -s < "${file}"
fi
done
+27
View File
@@ -0,0 +1,27 @@
# Description:
# TensorFlow is a computational framework, primarily for use in machine
# learning applications.
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
licenses = ["notice"],
)
sh_binary(
name = "parallel_gpu_execute",
srcs = ["parallel_gpu_execute.sh"],
)
filegroup(
name = "all_files",
srcs = glob(
["**/*"],
exclude = [
"**/METADATA",
"**/OWNERS",
],
),
visibility = ["//visibility:private"],
)
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
# Copyright 2016 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.
# ==============================================================================
#
#
# A script to run multiple GPU tests in parallel controlled with an environment
# variable.
#
# Required environment variables:
# TF_GPU_COUNT = Number of GPUs available.
TF_GPU_COUNT=${TF_GPU_COUNT:-4}
TF_TESTS_PER_GPU=${TF_TESTS_PER_GPU:-8}
# This function is used below in rlocation to check that a path is absolute
function is_absolute {
[[ "$1" = /* ]] || [[ "$1" =~ ^[a-zA-Z]:[/\\].* ]]
}
export TF_PER_DEVICE_MEMORY_LIMIT_MB=${TF_PER_DEVICE_MEMORY_LIMIT_MB:-2048}
# *******************************************************************
# This section of the script is needed to
# make things work on windows under msys.
# *******************************************************************
RUNFILES_MANIFEST_FILE="${TEST_SRCDIR}/MANIFEST"
function rlocation() {
if is_absolute "$1" ; then
# If the file path is already fully specified, simply return it.
echo "$1"
elif [[ -e "$TEST_SRCDIR/$1" ]]; then
# If the file exists in the $TEST_SRCDIR then just use it.
echo "$TEST_SRCDIR/$1"
elif [[ -e "$RUNFILES_MANIFEST_FILE" ]]; then
# If a runfiles manifest file exists then use it.
echo "$(grep "^$1 " "$RUNFILES_MANIFEST_FILE" | sed 's/[^ ]* //')"
fi
}
TEST_BINARY="$(rlocation $TEST_WORKSPACE/${1#./})"
shift
# *******************************************************************
mkdir -p /var/lock
# Try to acquire any of the TF_GPU_COUNT * TF_TESTS_PER_GPU
# slots to run a test at.
#
# Prefer to allocate 1 test per GPU over 4 tests on 1 GPU.
# So, we iterate over TF_TESTS_PER_GPU first.
for j in `seq 0 $((TF_TESTS_PER_GPU-1))`; do
for i in `seq 0 $((TF_GPU_COUNT-1))`; do
exec {lock_fd}>/var/lock/gpulock${i}_${j} || exit 1
if flock -n "$lock_fd";
then
(
# This export only works within the brackets, so it is isolated to one
# single command.
export CUDA_VISIBLE_DEVICES=$i
export HIP_VISIBLE_DEVICES=$i
echo "Running test $TEST_BINARY $* on GPU $CUDA_VISIBLE_DEVICES"
"$TEST_BINARY" $@
)
return_code=$?
flock -u "$lock_fd"
exit $return_code
fi
done
done
echo "Cannot find a free GPU to run the test $* on, exiting with failure..."
exit 1
@@ -0,0 +1,15 @@
# Running bazel inside a `docker build` command causes trouble, cf:
# https://github.com/bazelbuild/bazel/issues/134
# The easiest solution is to set up a bazelrc file forcing --batch.
startup --batch
# Similarly, we need to workaround sandboxing issues:
# https://github.com/bazelbuild/bazel/issues/418
build --verbose_failures --spawn_strategy=standalone --strategy=Genrule=standalone
test --spawn_strategy=standalone
# Force bazel output to use colors (good for jenkins) and print useful errors.
common --color=yes
# Configure tests - increase timeout, print errors and timeout warnings
test --verbose_failures --test_output=errors --test_verbose_timeout_warnings
+24
View File
@@ -0,0 +1,24 @@
"""Description: BUILD file for shell script to install bazel using the installer.
"""
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
licenses = ["notice"],
)
exports_files(
srcs = glob(["*.sh"]),
visibility = ["//visibility:public"],
)
sh_binary(
name = "install_bazel",
srcs = ["install_bazel.sh"],
)
sh_binary(
name = "install_bazel_from_source",
srcs = ["install_bazel_from_source.sh"],
)
@@ -0,0 +1,30 @@
#!/bin/bash -eu
# Copyright 2020 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.
# ==============================================================================
VERSION="$1"
NO_RC_VERSION="${VERSION%rc*}"
shift
mkdir /build
cd /build
wget "https://www.python.org/ftp/python/${NO_RC_VERSION}/Python-${VERSION}.tgz"
tar xvzf "Python-${VERSION}.tgz"
cd "Python-${VERSION}"
./configure "$@"
make -j$(nproc) altinstall
rm -rf /build
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Copyright 2015 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
sudo pip3 install auditwheel==2.0.0
# Pin wheel==0.31.1 to work around issue
# https://github.com/pypa/auditwheel/issues/102
sudo pip3 install wheel==0.31.1
set +e
patchelf_location=$(which patchelf)
if [[ -z "$patchelf_location" ]]; then
set -e
# Install patchelf from source (it does not come with trusty package)
wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2
tar xfa patchelf-0.9.tar.bz2
cd patchelf-0.9
./configure --prefix=/usr/local
make
sudo make install
fi
cd ..
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# ==============================================================================
BAZEL_VERSION="7.7.0"
set +e
local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}')
if [[ "$local_bazel_ver" == "$BAZEL_VERSION" ]]; then
exit 0
fi
set -e
# Install bazel.
mkdir -p /bazel
cd /bazel
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
# Enable bazel auto completion.
echo "source /usr/local/lib/bazel/bin/bazel-complete.bash" >> ~/.bashrc
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Copyright 2018 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.
# ==============================================================================
# This script is to be used to install bzel on non x86_64 systems
# It will compile bazel from source and install it in /usr/local/bin
BAZEL_VERSION="6.5.0"
set +e
local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}')
if [[ "$local_bazel_ver" == "$BAZEL_VERSION" ]]; then
exit 0
fi
set -e
# Compile bazel from source
mkdir -p /bazel
cd /bazel
curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-dist.zip
unzip bazel-$BAZEL_VERSION-dist.zip
env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
cp output/bazel /usr/local/bin/
rm -rf /bazel
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Copyright 2015 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
# Retry on connection timeout.
bash -c "echo 'APT::Acquire::Retries \"3\";' > /etc/apt/apt.conf.d/80-retries"
# Install bootstrap dependencies from ubuntu deb repository.
apt-get update
apt-get install -y --no-install-recommends \
apt-transport-https ca-certificates software-properties-common
apt-get clean
rm -rf /var/lib/apt/lists/*
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright 2015 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
# Download buildifier.
wget https://github.com/bazelbuild/buildtools/releases/download/0.4.5/buildifier
chmod +x buildifier
sudo mv buildifier /usr/local/bin/.
# Download buildozer.
wget https://github.com/bazelbuild/buildtools/releases/download/0.4.5/buildozer
chmod +x buildozer
sudo mv buildozer /usr/local/bin/.
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Copyright 2018 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
BUILDTOOLS_VERSION="0.11.1"
# Clone buildtools
git clone -b $BUILDTOOLS_VERSION https://github.com/bazelbuild/buildtools
cd buildtools
# Build buildifier
bazel build //buildifier
sudo mv bazel-bin/buildifier/linux*stripped/buildifier /usr/local/bin
# Build buildozer
bazel build //buildozer
sudo mv bazel-bin/buildozer/linux*stripped/buildozer /usr/local/bin
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
# Copyright 2015 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
pip2 install -U pip==18.1
pip3 install -U pip==18.1
pip2 install wheel==0.31.1
pip3 install wheel==0.31.1
# Install last working version of setuptools. This must happen before we install
# absl-py, which uses install_requires notation introduced in setuptools 20.5.
pip2 install --upgrade setuptools==39.1.0
pip3 install --upgrade setuptools==39.1.0
pip2 install virtualenv
pip3 install virtualenv
# Install six.
pip2 install --upgrade six==1.12.0
pip3 install --upgrade six==1.12.0
# Install absl-py.
pip2 install --upgrade absl-py
pip3 install --upgrade absl-py
# Install werkzeug.
pip2 install --upgrade werkzeug==0.11.10
pip3 install --upgrade werkzeug==0.11.10
# Install bleach. html5lib will be picked up as a dependency.
pip2 install --upgrade bleach==2.0.0
pip3 install --upgrade bleach==2.0.0
# Install markdown.
pip2 install --upgrade markdown==2.6.8
pip3 install --upgrade markdown==2.6.8
# Install protobuf.
pip2 install --upgrade protobuf==3.16.0
pip3 install --upgrade protobuf==3.16.0
pip2 install --upgrade numpy==1.14.5
pip3 install --upgrade numpy~=1.19.2
pip2 install scipy==1.2.2
pip3 install scipy==1.4.1
pip2 install scikit-learn==0.18.1
pip3 install scikit-learn==0.18.1
# pandas required by `inflow`
pip2 install pandas==0.19.2
pip3 install pandas==0.19.2
# Benchmark tests require the following:
pip2 install psutil
pip2 install py-cpuinfo
pip3 install py-cpuinfo
# pylint tests require the following:
pip2 install pylint==1.6.4
pip3 install pylint==2.7.4
# pycodestyle tests require the following:
pip2 install pycodestyle
pip3 install pycodestyle
# tf.mock require the following for python2:
pip2 install mock
pip2 install portpicker
pip3 install portpicker
# TensorFlow Serving integration tests require the following:
pip2 install grpcio
pip3 install grpcio
# Eager-to-graph execution needs astor, gast and termcolor:
pip2 install --upgrade astor
pip3 install --upgrade astor
pip2 install --upgrade gast
pip3 install --upgrade gast
pip2 install --upgrade termcolor
pip3 install --upgrade termcolor
# Keras
pip2 install keras-nightly --no-deps
pip3 install keras-nightly --no-deps
pip2 install --upgrade h5py==2.8.0
pip3 install --upgrade h5py==3.1.0
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright 2019 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.
# ==============================================================================
cd /usr/src
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
tar xzf Python-3.6.8.tgz
cd Python-3.6.8
./configure --enable-optimizations
make altinstall
rm /usr/src/Python-3.6.8.tgz
# Link the pip3.6 executable to pip3.
ln -s /usr/local/bin/pip3.6 /usr/local/bin/pip3
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash -eu
# Copyright 2016 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.
# ==============================================================================
DIST="$(grep "DISTRIB_CODENAME" /etc/lsb-release |sed 's,.*=,,')"
wget -O - "https://apt.llvm.org/llvm-snapshot.gpg.key"| apt-key add -
add-apt-repository "deb http://apt.llvm.org/${DIST}/ llvm-toolchain-${DIST}-8 main"
apt-get update && apt-get install -y clang-8 && \
rm -rf /var/lib/apt/lists/*
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash -eu
# Copyright 2023 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.
# ==============================================================================
# LLVM/Clang: https://apt.llvm.org/
apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
# Set up custom sources
cat >/etc/apt/sources.list.d/custom.list <<SOURCES
# LLVM/Clang repository
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
SOURCES
apt-get update && apt-get install -y \
llvm-17 \
clang-17 \
lld-17
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash -eu
# Copyright 2023 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.
# ==============================================================================
# LLVM/Clang: https://apt.llvm.org/
apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
# Set up custom sources
cat >/etc/apt/sources.list.d/custom.list <<SOURCES
# LLVM/Clang repository
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main
SOURCES
apt-get autoremove clang-17 -y || true # Remove clang-17 if it exists.
apt-get update && apt-get install -y \
llvm-18 \
clang-18 \
lld-18 \
clang-tidy-18 \
clang-format-12
/usr/lib/llvm-18/bin/clang --version
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Copyright 2021 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.
# ==============================================================================
curl -OL https://github.com/Kitware/CMake/releases/download/v3.16.8/cmake-3.16.8-Linux-x86_64.sh
echo "0241a05bee0dcdf60e912057cc86cbedba21b9b0d67ec11bc67ad4834f182a23 cmake-3.16.8-Linux-x86_64.sh" | sha256sum -c
sh cmake-3.16.8-Linux-x86_64.sh --prefix=/usr --skip-license
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# ==============================================================================
#
# Usage:
# ./install_deb_packages [--without_cmake]
# Pass --without_cmake to prevent cmake from being installed with apt-get
set -e
ubuntu_version=$(cat /etc/issue | grep -i ubuntu | awk '{print $2}' | \
awk -F'.' '{print $1}')
if [[ "$1" != "" ]] && [[ "$1" != "--without_cmake" ]]; then
echo "Unknown argument '$1'"
exit 1
fi
if [[ "$ubuntu_version" == "18" ]]; then
apt-get update
apt-get install -y gnupg2
fi
# Install dependencies from ubuntu deb repository.
apt-key adv --keyserver keyserver.ubuntu.com --recv 084ECFC5828AB726
apt-get update
if [[ "$ubuntu_version" == "14" ]]; then
# specifically for trusty linked from ffmpeg.org
add-apt-repository -y ppa:mc3man/trusty-media
apt-get update
apt-get dist-upgrade -y
fi
## TODO(yifeif) remove ffmpeg once ffmpeg is removed from contrib
apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
curl \
ffmpeg \
git \
libcurl4-openssl-dev \
libtool \
libssl-dev \
mlocate \
openjdk-8-jdk \
openjdk-8-jre-headless \
pkg-config \
python-setuptools \
python3-virtualenv \
python3-dev \
python3-setuptools \
rsync \
sudo \
swig \
unzip \
vim \
wget \
zip \
zlib1g-dev
# populate the database
updatedb
if [[ "$1" != "--without_cmake" ]]; then
apt-get install -y --no-install-recommends \
cmake
fi
# Install ca-certificates, and update the certificate store.
apt-get install -y ca-certificates-java
update-ca-certificates -f
apt-get clean
rm -rf /var/lib/apt/lists/*
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright 2017 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.
# ==============================================================================
apt-get update
apt-get install build-essential software-properties-common -y
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update
apt-get install gcc-snapshot -y
apt-get update
apt-get install gcc-6 g++-6 -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 100 --slave /usr/bin/g++ g++ /usr/bin/g++-6
update-alternatives --set gcc /usr/bin/gcc-6
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Copyright 2017 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 -ex
GOLANG_URL="https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz"
sudo mkdir -p /usr/local
wget -q -O - "${GOLANG_URL}" | sudo tar -C /usr/local -xz
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright 2019 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 -ex
GOLANG_URL="https://dl.google.com/go/go1.12.6.linux-amd64.tar.gz"
cd /usr/src
wget "${GOLANG_URL}"
tar -xzf go1.12.6.linux-amd64.tar.gz
mv go /usr/local
rm /usr/src/go1.12.6.linux-amd64.tar.gz
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Copyright 2018 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 -ex
GOLANG_URL="https://storage.googleapis.com/golang/go1.10.linux-ppc64le.tar.gz"
sudo mkdir -p /usr/local
wget -q -O - "${GOLANG_URL}" | sudo tar -C /usr/local -xz
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright 2015 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
mpiexec=$(which mpiexec)
if [[ -z "$mpiexec_location" ]]; then
# Install dependencies from ubuntu deb repository.
apt-get update
apt-get install -y --no-install-recommends openmpi-bin libopenmpi-dev
fi
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2018 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.
# ==============================================================================
OPENBLAS_SRC_PATH=/tmp/openblas_src/
POWER="POWER8"
USE_OPENMP="USE_OPENMP=1"
OPENBLAS_INSTALL_PATH="/usr"
apt-get update
apt-get install -y gfortran gfortran-5
apt-get clean
rm -rf /var/lib/apt/lists/*
rm -rf ${OPENBLAS_SRC_PATH}
git clone -b v0.3.7 https://github.com/xianyi/OpenBLAS ${OPENBLAS_SRC_PATH}
cd ${OPENBLAS_SRC_PATH}
make TARGET=${POWER} ${USE_OPENMP} FC=gfortran
make PREFIX=${OPENBLAS_INSTALL_PATH} install
@@ -0,0 +1,17 @@
#!/bin/bash -eu
# Copyright 2020 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.
# ==============================================================================
apt-get update && apt-get install -y patchelf
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Copyright 2017 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.
# ==============================================================================
yes | add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install -y python3.9 python3.9-dev
apt-get install -y python3-pip
ln -sf /usr/bin/python3.9 /usr/local/bin/python3.9
apt-get install -y python3.9-distutils
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
update-alternatives --set python3 /usr/bin/python3.9
pip3 install --upgrade pip
# python3.9 -m pip install --upgrade pip
source /install/common.sh
install_ubuntu_16_python_pip_deps python3.9
cp -r /root//.local/lib/python3.9/site-packages/* /usr/lib/python3/dist-packages/.
ln -sf /root//.local/lib/python3.9/site-packages/numpy/core/include/numpy /usr/include/python3.9/numpy
rm -f /usr/bin/python3 && ln -s /usr/bin/python3.9 /usr/bin/python3
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright 2017 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 -x
PYTHON_VERSION=$1
dpkg --add-architecture armhf
dpkg --add-architecture arm64
debian_codename=$(lsb_release -c | awk '{print $2}')
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ ${debian_codename} main restricted universe multiverse" >> /etc/apt/sources.list.d/armhf.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ ${debian_codename}-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/armhf.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ ${debian_codename}-security main restricted universe multiverse" >> /etc/apt/sources.list.d/armhf.list
echo "deb [arch=arm64,armhf] http://ports.ubuntu.com/ ${debian_codename}-backports main restricted universe multiverse" >> /etc/apt/sources.list.d/armhf.list
sed -i 's#deb http://archive.ubuntu.com/ubuntu/#deb [arch=amd64] http://archive.ubuntu.com/ubuntu/#g' /etc/apt/sources.list
yes | add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev
apt-get install -y python${PYTHON_VERSION}-venv
#/usr/local/bin/python3.x is needed to use /install/install_pip_packages_by_version.sh
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/local/bin/python${PYTHON_VERSION}
apt-get install -y libpython${PYTHON_VERSION}-dev:armhf
apt-get install -y libpython${PYTHON_VERSION}-dev:arm64
SPLIT_VERSION=(`echo ${PYTHON_VERSION} | tr -s '.' ' '`)
if [[ SPLIT_VERSION[0] -eq 3 ]] && [[ SPLIT_VERSION[1] -ge 8 ]]; then
apt-get install -y python${PYTHON_VERSION}-distutils
fi
/install/install_pip_packages_by_version.sh "/usr/local/bin/pip${PYTHON_VERSION}"
ln -sf /usr/local/lib/python${PYTHON_VERSION}/dist-packages/numpy/core/include/numpy /usr/include/python${PYTHON_VERSION}/numpy
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright 2017 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.
# ==============================================================================
dpkg --add-architecture armhf
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
sed -i 's#deb http://archive.ubuntu.com/ubuntu/#deb [arch=amd64] http://archive.ubuntu.com/ubuntu/#g' /etc/apt/sources.list
apt-get update
apt-get install -y libpython-all-dev:armhf
apt-get install -y python python-numpy python-dev python-pip
+113
View File
@@ -0,0 +1,113 @@
#!/usr/bin/env bash
# Copyright 2015 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
# Get the latest version of pip so it recognize manylinux2010
wget https://bootstrap.pypa.io/get-pip.py
python3.6 get-pip.py
rm -f get-pip.py
# Install pip packages from whl files to avoid the time-consuming process of
# building from source.
# Pin wheel==0.31.1 to work around issue
# https://github.com/pypa/auditwheel/issues/102
pip3 install wheel==0.31.1
# Install last working version of setuptools. This must happen before we install
# absl-py, which uses install_requires notation introduced in setuptools 20.5.
pip3 install --upgrade setuptools==39.1.0
pip3 install virtualenv
# Install six and future.
pip3 install --upgrade six==1.12.0
pip3 install "future>=0.17.1"
# Install absl-py.
pip3 install --upgrade absl-py
# Install werkzeug.
pip3 install --upgrade werkzeug==0.11.10
# Install bleach. html5lib will be picked up as a dependency.
pip3 install --upgrade bleach==2.0.0
# Install markdown.
pip3 install --upgrade markdown==2.6.8
# Install protobuf.
pip3 install --upgrade protobuf==3.16.0
# Remove obsolete version of six, which can sometimes confuse virtualenv.
rm -rf /usr/lib/python3/dist-packages/six*
# numpy needs to be installed from source to fix segfaults. See:
# https://github.com/tensorflow/tensorflow/issues/6968
# This workaround isn't needed for Ubuntu 16.04 or later.
if $(cat /etc/*-release | grep -q 14.04); then
pip3 install --upgrade numpy==1.14.5
else
pip3 install --upgrade numpy~=1.19.2
fi
pip3 install scipy==1.4.1
pip3 install scikit-learn==0.18.1
# pandas required by `inflow`
pip3 install pandas==0.19.2
# Benchmark tests require the following:
pip3 install psutil
pip3 install py-cpuinfo
# pylint tests require the following version. pylint==1.6.4 hangs erratically,
# thus using the updated version of 2.5.3 only for python3 as python2 is EOL
# and this version is not available.
pip3 install pylint==2.7.4
# pycodestyle tests require the following:
pip3 install pycodestyle
pip3 install portpicker
# TensorFlow Serving integration tests require the following:
pip3 install grpcio
# Eager-to-graph execution needs astor, gast and termcolor:
pip3 install --upgrade astor
pip3 install --upgrade gast
pip3 install --upgrade termcolor
# Keras
pip3 install keras-nightly --no-deps
pip3 install --upgrade h5py==3.1.0
# Tensorboard
pip3 install tb-nightly --no-deps
# Argparse
pip3 install --upgrade argparse
# tree
pip3 install dm-tree
# tf.distribute multi worker tests require the following:
# Those tests are Python3 only.
pip3 install --upgrade dill
pip3 install --upgrade tblib

Some files were not shown because too many files have changed in this diff Show More