Skip to content

Adding release dockerfile and script #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions tensorflow/tools/ci_build/linux/mkl/Dockerfile.devel-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
ARG ROOT_CONTAINER_TAG=devel
ARG ROOT_CONTAINER=tensorflow/tensorflow

FROM ${ROOT_CONTAINER}:${ROOT_CONTAINER_TAG}

LABEL maintainer="Clayne Robison <clayne.b.robison@intel.com>"

# These parameters can be overridden
ARG PYTHON="python"
ARG WHL_DIR="/tmp/pip"
ARG PIP="pip"
ARG TARGET_PLATFORM="haswell"
ARG CONFIG_V2_DISABLE=""
ARG CONFIG_BFLOAT16_BUILD=""
ARG ENABLE_SECURE_BUILD
ARG BAZEL_VERSION=""
ARG ENABLE_DNNL1=""
ARG ENABLE_HOROVOD=""

ENV DEBIAN_FRONTEND=noninteractive

# Upgrade Bazel version if argument is passed
RUN if [ "${BAZEL_VERSION}" != "" ]; then \
curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
chmod +x bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
rm -rf bazel-$BAZEL_VERSION-installer-linux-x86_64.sh; \
fi

# Remove crypto python packages due to SWLC
RUN ${PIP} uninstall --yes cryptography && \
rm -rf /usr/lib/python3/dist-packages/pycrypto-2.6.1.egg-info;

# Donwload and build Intel TensorFlow
# make sure that if they pass in a tag, that it is loaded or we'll get an error
WORKDIR /

COPY tensorflow/ /tensorflow/

WORKDIR /tensorflow

RUN yes "" | ${PYTHON} configure.py

ENV CI_BUILD_PYTHON ${PYTHON}

# This script detects the version of gcc in the container, sets the appropriate
# compiler flags based on parameters
ADD set-build-env.py .
RUN ${PYTHON} set-build-env.py -p ${TARGET_PLATFORM} -f /root/.mkl.bazelrc \
${CONFIG_V2_DISABLE} ${ENABLE_SECURE_BUILD} ${CONFIG_BFLOAT16_BUILD} ${ENABLE_DNNL1}

# Pull the compiler flags we just wrote into root user's .bazelrc file
RUN echo "import /root/.mkl.bazelrc" >>/root/.bazelrc

# Clean up Bazel cache when done.
# Clean up Intel-TF whl: Requirement specific to CPX launch
RUN bazel --bazelrc=/root/.bazelrc build -c opt \
tensorflow/tools/pip_package:build_pip_package && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package "${WHL_DIR}" && \
${PIP} --no-cache-dir install --upgrade "${WHL_DIR}"/tensorflow-*.whl && \
rm -rf /root/.cache

#Install OpenMPI/Horovod
COPY install_openmpi_horovod_release.sh .
RUN if [ "${ENABLE_HOROVOD}" = "yes" ]; then \
chmod +x install_openmpi_horovod_release.sh && \
./install_openmpi_horovod_release.sh && \
rm -rf install_openmpi_horovod_release.sh; \
fi

# TensorBoard
EXPOSE 6006
# IPython
EXPOSE 8888

WORKDIR /root
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# install OpenMPI, Horovod and gcc8

set -e

# Install Open MPI
#apt-get install -y --no-install-recommends openmpi-bin openmpi-common libopenmpi-dev
OPENMPI_VERSION=openmpi-2.1.1
OPENMPI_DOWNLOAD_URL=https://www.open-mpi.org/software/ompi/v2.1/downloads/${OPENMPI_VERSION}.tar.gz

mkdir /tmp/openmpi
cd /tmp/openmpi
curl -fSsL -O ${OPENMPI_DOWNLOAD_URL}
tar zxf ${OPENMPI_VERSION}.tar.gz
cd ${OPENMPI_VERSION}
./configure --enable-mpirun-prefix-by-default
make -j $(nproc) all
make install
ldconfig
cd /
rm -rf /tmp/openmpi

# Create a wrapper for OpenMPI to allow running as root by default
mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real
echo '#!/bin/bash' > /usr/local/bin/mpirun
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun
chmod a+x /usr/local/bin/mpirun

# Configure OpenMPI to run good defaults:
echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf

#Check mpi version
echo 'OpenMPI version:'
mpirun --version

#Install Horovod
HOROVOD_WITH_TENSORFLOW=1
python3 -m pip install --no-cache-dir horovod==0.19.1