1ARG ROOT_CONTAINER_TAG=devel 2ARG ROOT_CONTAINER=tensorflow/tensorflow 3 4FROM ${ROOT_CONTAINER}:${ROOT_CONTAINER_TAG} 5 6LABEL maintainer="Clayne Robison <clayne.b.robison@intel.com>" 7 8# These parameters can be overridden 9ARG PYTHON="python" 10ARG WHL_DIR="/tmp/pip" 11ARG PIP="pip" 12ARG TARGET_PLATFORM="haswell" 13ARG CONFIG_V2_DISABLE="" 14ARG CONFIG_BFLOAT16_BUILD="" 15ARG ENABLE_SECURE_BUILD 16ARG BAZEL_VERSION="" 17ARG ENABLE_DNNL1="" 18ARG ENABLE_HOROVOD="" 19ARG ENABLE_GCC8="" 20ARG OPENMPI_VERSION="" 21ARG OPENMPI_DOWNLOAD_URL="" 22ARG HOROVOD_VERSION="" 23ARG INSTALL_HOROVOD_FROM_COMMIT="" 24ARG BUILD_SSH="" 25ARG TF_NIGHTLY_FLAG="" 26ARG RELEASE_CONTAINER="" 27 28ENV DEBIAN_FRONTEND=noninteractive 29 30# Upgrade Bazel version if argument is passed 31RUN if [ "${BAZEL_VERSION}" != "" ]; then \ 32 curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ 33 chmod +x bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ 34 ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ 35 rm -rf bazel-$BAZEL_VERSION-installer-linux-x86_64.sh; \ 36 fi 37 38# Upgrade gcc-8 if argument is passed 39RUN if [ "${ENABLE_GCC8}" = "yes" ]; then \ 40 add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ 41 apt-get update && \ 42 apt-get install gcc-8 g++-8 -y && \ 43 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 && \ 44 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7 ;\ 45 fi 46 47# Download and build TensorFlow from the latest sources found in the root container 48# make sure that if they pass in a tag, that it is loaded or we'll get an error 49WORKDIR / 50 51COPY tensorflow/ /tensorflow/ 52 53WORKDIR /tensorflow 54 55RUN yes "" | ${PYTHON} configure.py 56 57ENV CI_BUILD_PYTHON ${PYTHON} 58 59# This script detects the version of gcc in the container, sets the appropriate 60# compiler flags based on parameters 61ADD set-build-env.py . 62RUN ${PYTHON} set-build-env.py -p ${TARGET_PLATFORM} -f /root/.mkl.bazelrc \ 63 ${CONFIG_V2_DISABLE} ${ENABLE_SECURE_BUILD} ${CONFIG_BFLOAT16_BUILD} ${ENABLE_DNNL1} 64 65# Pull the compiler flags we just wrote into root user's .bazelrc file 66RUN echo "import /root/.mkl.bazelrc" >>/root/.bazelrc 67 68# Install futures>=0.17.1 for Python2.7 compatibility mode 69RUN ${PIP} install future>=0.17.1 70 71RUN bazel --bazelrc=/root/.bazelrc build -c opt \ 72 tensorflow/tools/pip_package:build_pip_package && \ 73 bazel-bin/tensorflow/tools/pip_package/build_pip_package "${TF_NIGHTLY_FLAG}" "${WHL_DIR}" && \ 74 ${PIP} --no-cache-dir install --upgrade "${WHL_DIR}"/*.whl && \ 75 rm -rf /root/.cache 76 # Clean up Bazel cache when done. 77 78# Install OpenMPI/Horovod 79COPY install_openmpi_horovod.sh . 80RUN if [ "${ENABLE_HOROVOD}" = "yes" ]; then \ 81 chmod +x install_openmpi_horovod.sh && \ 82 OPENMPI_VERSION=${OPENMPI_VERSION} OPENMPI_DOWNLOAD_URL=${OPENMPI_DOWNLOAD_URL} BUILD_SSH=${BUILD_SSH} \ 83 INSTALL_HOROVOD_FROM_COMMIT=${INSTALL_HOROVOD_FROM_COMMIT} HOROVOD_VERSION=${HOROVOD_VERSION} ./install_openmpi_horovod.sh && \ 84 rm -rf install_openmpi_horovod.sh; \ 85 fi 86 87# Remove crypto python packages for software compliance check. 88RUN if [ "${RELEASE_CONTAINER}" = "yes" ]; then \ 89 ${PIP} uninstall --yes cryptography && \ 90 rm -rf /usr/lib/python3/dist-packages/pycrypto-2.6.1.egg-info; \ 91 fi 92 93# TensorBoard 94EXPOSE 6006 95# IPython 96EXPOSE 8888 97 98WORKDIR /root 99