forked from tensorflow/tensorflow
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile partials to support Mkl + MPI + Horovod; Remove traili…
…ng whitespace from python.partial.Dockerfile
- Loading branch information
1 parent
eae5d0b
commit 3023584
Showing
7 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
tensorflow/tools/dockerfiles/partials/devel-horovod.partial.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Check out horovod source code if --build-arg CHECKOUT_HOROVOD_SRC=1 | ||
ARG CHECKOUT_HOROVOD_SRC=0 | ||
RUN test "${CHECKOUT_HOROVOD_SRC}" -eq 1 && git clone --recursive https://github.com/uber/horovod.git /horovod_src || true |
2 changes: 2 additions & 0 deletions
2
tensorflow/tools/dockerfiles/partials/horovod.partial.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Install Horovod | ||
RUN ${PIP} install --no-cache-dir horovod |
44 changes: 44 additions & 0 deletions
44
tensorflow/tools/dockerfiles/partials/mpi.partial.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# install libnuma, openssh, wget | ||
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \ | ||
libnuma-dev \ | ||
openssh-server \ | ||
openssh-client \ | ||
wget && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* || \ | ||
yum -y update && yum -y install \ | ||
numactl-devel \ | ||
openssh-server \ | ||
openssh-clients \ | ||
wget && \ | ||
yum clean all || \ | ||
echo "Unsupported Linux distribution. Aborting!" && exit 1 | ||
|
||
# Install Open MPI | ||
RUN mkdir /tmp/openmpi && \ | ||
cd /tmp/openmpi && \ | ||
wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.0.tar.gz && \ | ||
tar zxf openmpi-4.0.0.tar.gz && \ | ||
cd openmpi-4.0.0 && \ | ||
./configure --enable-orterun-prefix-by-default && \ | ||
make -j $(nproc) all && \ | ||
make install && \ | ||
ldconfig && \ | ||
rm -rf /tmp/openmpi | ||
|
||
# Create a wrapper for OpenMPI to allow running as root by default | ||
RUN 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: | ||
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf | ||
|
||
# Install OpenSSH for MPI to communicate between containers | ||
RUN mkdir -p /var/run/sshd | ||
|
||
# Allow OpenSSH to talk to containers without asking for confirmation | ||
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \ | ||
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \ | ||
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/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. | ||
# ============================================================================ | ||
|
||
|
||
|
||
# Download and build TensorFlow. | ||
set -euxo pipefail | ||
git clone --branch=master --depth=1 https://github.com/tensorflow/tensorflow.git /tensorflow | ||
cd /tensorflow | ||
|
||
ln -s $(which ${PYTHON}) /usr/local/bin/python | ||
|
||
# Build TensorFlow with support for Intel(R) MKL-DNN | ||
yes "" | ${PYTHON} configure.py && \ | ||
bazel build -c opt --config=mkl --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \ | ||
tensorflow/tools/pip_package:build_pip_package && \ | ||
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip && \ | ||
pip --no-cache-dir install --upgrade /tmp/pip/tensorflow-*.whl && \ | ||
rm -rf /tmp/pip && \ | ||
rm -rf /root/.cache | ||
|
||
|
||
# download and build Horovod | ||
git clone --recursive https://github.com/uber/horovod.git | ||
cd horovod | ||
# export environment | ||
export HOROVOD_WITHOUT_PYTORCH=1 | ||
export HOROVOD_WITH_TENSORFLOW=1 | ||
python setup.py sdist | ||
pip --no-cache-dir install --upgrade sdist/horovod*.tar.gz && \ | ||
rm -rf sdist && \ | ||
rm -rf /root/.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/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. | ||
# ============================================================================ | ||
|
||
python -c 'from tensorflow.python import pywrap_tensorflow; pywrap_tensorflow.IsMklEnabled() or exit(1); import horovod.tensorflow as hvd' |