Skip to content

Commit e8a6be1

Browse files
committed
support DALI on Tensorflow 1.13 for CPU
1 parent a625c41 commit e8a6be1

File tree

1 file changed

+21
-214
lines changed

1 file changed

+21
-214
lines changed

python-tensorflow/Dockerfile.1.13-py36

Lines changed: 21 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,8 @@
1-
FROM ubuntu:18.04
1+
FROM lablup/common-base:20.08-py36
22

3-
4-
# These parameters can be overridden by parameterized_docker_build.sh
53
ARG TF_BUILD_VERSION=r1.13
6-
ARG PYTHON="python"
7-
ARG PYTHON_VERSION=3.6
8-
ARG PYTHON3_DEV=""
9-
ARG WHL_DIR="/tmp/pip"
10-
ARG PIP="pip"
11-
12-
ENV DEBIAN_FRONTEND=noninteractive \
13-
MPLBACKEND=Svg \
14-
PYTHONUNBUFFERED=1 \
15-
LANG=C.UTF-8
16-
17-
# Set default shell to /bin/bash
18-
SHELL ["/bin/bash", "-cu"]
19-
20-
RUN apt-get update -y && \
21-
apt-get install -y --no-install-recommends software-properties-common && \
22-
add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
23-
apt-get update -y && \
24-
apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
25-
build-essential \
26-
ca-certificates \
27-
gcc g++ make \
28-
gfortran \
29-
dkms \
30-
git \
31-
curl \
32-
vim \
33-
yasm \
34-
wget zip unzip \
35-
software-properties-common \
36-
openssh-client openssh-server \
37-
libssl-dev \
38-
libmpdec2 \
39-
pdsh curl net-tools \
40-
iputils-ping \
41-
libcurl3-dev \
42-
libfreetype6-dev \
43-
libhdf5-serial-dev \
44-
libzmq3-dev \
45-
libjpeg-dev \
46-
libpng-dev \
47-
libsm6 \
48-
libxext6 \
49-
libxrender-dev \
50-
libcairo2-dev libgirepository1.0-dev pkg-config gir1.2-gtk-3.0 \
51-
libgeos-dev libgeos++-dev \
52-
pkg-config \
53-
gpg-agent \
54-
zlib1g-dev \
55-
mime-support \
56-
proj-bin libproj-dev libgeos-dev libgeos++-dev graphviz \
57-
python${PYTHON_VERSION} \
58-
python${PYTHON_VERSION}-dev \
59-
libxml2-dev \
60-
libxslt1-dev \
61-
libasound2-dev \
62-
libnuma-dev \
63-
libtiff-dev \
64-
libavcodec-dev \
65-
libavformat-dev \
66-
libswscale-dev \
67-
libxine2-dev \
68-
libv4l-dev \
69-
libboost-dev \
70-
libboost-system-dev \
71-
libboost-filesystem-dev \
72-
xvfb \
73-
fonts-nanum \
74-
fonts-nanum-coding \
75-
fonts-nanum-extra \
76-
rsync \
77-
openjdk-8-jdk \
78-
openjdk-8-jre-headless \
79-
openssh-client \
80-
openssh-server \
81-
&& \
82-
apt-get clean && \
83-
rm -rf /var/lib/apt/lists/*
84-
85-
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
86-
apt-get update -y && \
87-
apt-get install -y nodejs
88-
89-
# OFED
90-
ENV STAGE_DIR=/tmp
91-
RUN mkdir -p ${STAGE_DIR}
92-
ENV MLNX_OFED_VERSION=4.6-1.0.1.1
93-
RUN cd ${STAGE_DIR} && \
94-
wget -q -O - http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64.tgz | tar xzf -
95-
RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
96-
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
97-
cd ${STAGE_DIR} && \
98-
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
99-
100-
RUN if [[ "${PYTHON_VERSION}" == "3.6" ]]; then \
101-
apt-get install -y python${PYTHON_VERSION}-distutils python-apt ; \
102-
fi
103-
104-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
105-
106-
WORKDIR /tmp
107-
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \
108-
python3 -m pip install --no-cache-dir -U setuptools pip
109-
110-
111-
RUN if [ "${PYTHON}" = "python3" ]; then \
112-
ln -s -f /usr/bin/python3 /usr/bin/python; \
113-
fi
114-
115-
COPY ./numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl /tmp
116-
COPY ./pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl /tmp
117-
118-
RUN python3 -m pip install --no-cache-dir --upgrade -Iv \
119-
Pillow \
120-
h5py \
121-
ipykernel \
122-
jupyter \
123-
mock \
124-
Cython==0.29.20 \
125-
/tmp/numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl \
126-
/tmp/pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl \
127-
tornado==6.0.4 \
128-
pystan==2.19.1.1 \
129-
pycairo==1.19.0 \
130-
python-language-server[all] \
131-
keras_applications \
132-
keras_preprocessing \
133-
sklearn \
134-
matplotlib==3.1.1
135-
136-
RUN python3 -m pip install pip --no-cache-dir \
137-
Cartopy==0.18.0 \
138-
notebook==6.0.3
139-
140-
WORKDIR /tmp
141-
RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \
142-
cd OpenBLAS && \
143-
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
144-
make install
145-
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
146-
cd /tmp/scs-python && \
147-
python3 setup.py install --scs
148-
4+
# Install the most recent bazel release.
5+
ENV BAZEL_VERSION 0.20.0
1496

1507
# Set up Bazel.
1518

@@ -157,8 +14,7 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
15714
# https://github.com/bazelbuild/bazel/issues/418
15815
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
15916
>>/etc/bazel.bazelrc
160-
# Install the most recent bazel release.
161-
ENV BAZEL_VERSION 0.20.0
17+
16218
WORKDIR /
16319
RUN mkdir /bazel && \
16420
cd /bazel && \
@@ -184,7 +40,7 @@ RUN export TAG_PREFIX="v" && \
18440
git clone --depth=1 --branch=${TF_BUILD_VERSION} https://github.com/tensorflow/tensorflow.git . ; \
18541
fi
18642

187-
RUN yes "" | ${PYTHON} configure.py
43+
RUN yes "" | python3 configure.py
18844
RUN cp .bazelrc /root/.bazelrc
18945

19046
ENV CI_BUILD_PYTHON ${PYTHON}
@@ -199,79 +55,30 @@ ENV WHL_DIR=/tmp/pip3
19955
COPY .bazelrc /root/.mkl.bazelrc
20056
RUN echo "import /root/.mkl.bazelrc" >>/root/.bazelrc
20157

202-
RUN tensorflow/tools/ci_build/builds/configured CPU \
58+
RUN tensorflow/tools/ci_build/builds/configured CPU \
20359
bazel --bazelrc=/root/.bazelrc build -c opt \
60+
--config=mkl \
61+
--copt=-mavx \
62+
--copt=-mavx2 \
63+
--config=monolithic \
64+
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
20465
tensorflow/tools/pip_package:build_pip_package && \
20566
bazel-bin/tensorflow/tools/pip_package/build_pip_package "${WHL_DIR}" && \
20667
python3 -m pip --no-cache-dir install --upgrade "${WHL_DIR}"/tensorflow-*.whl && \
68+
python3 -m pip --no-cache-dir install \
69+
tensorboard==1.13.0 && \
20770
rm -rf /root/.cache
20871
# Clean up Bazel cache when done.
20972

210-
WORKDIR /root
211-
212-
# Install Open MPI
213-
RUN mkdir /tmp/openmpi && \
214-
cd /tmp/openmpi && \
215-
wget https://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.0.tar.gz && \
216-
tar zxf openmpi-3.0.0.tar.gz && \
217-
cd openmpi-3.0.0 && \
218-
./configure --enable-orterun-prefix-by-default && \
219-
make -j $(nproc) all && \
220-
make install && \
221-
ldconfig && \
222-
rm -rf /tmp/openmpi
223-
224-
# Create a wrapper for OpenMPI to allow running as root by default
225-
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
226-
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
227-
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
228-
chmod a+x /usr/local/bin/mpirun
229-
230-
# Configure OpenMPI to run good defaults:
231-
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
232-
233-
# Install Horovod
234-
RUN python3 -m pip --no-cache-dir install \
235-
horovod
236-
RUN python3 -m pip --no-cache-dir install \
237-
jupyter_contrib_nbextensions \
238-
jupyter_lsp \
239-
jupyterlab-nvdashboard \
240-
# tensorflow-model-analysis \
241-
jupyterlab
242-
243-
244-
# Install OpenSSH for MPI to communicate between containers
245-
RUN mkdir -p /var/run/sshd
246-
247-
# Allow OpenSSH to talk to containers without asking for confirmation
248-
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
249-
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
250-
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
251-
252-
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.11.0/git-lfs-linux-amd64-v2.11.0.tar.gz && \
253-
tar -zxf git-lfs-linux-amd64-v2.11.0.tar.gz && \
254-
bash install.sh && \
255-
rm -rf /tmp/*
256-
257-
COPY ./service-defs /etc/backend.ai/service-defs
258-
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.4.1/code-server-3.4.1-linux-amd64.tar.gz \
259-
| tar -C /usr/local/lib -xz && \
260-
mv /usr/local/lib/code-server-3.4.1-linux-amd64 /usr/local/lib/code-server-3.4.1 && \
261-
ln -s /usr/local/lib/code-server-3.4.1/bin/code-server /usr/local/bin/code-server
262-
263-
RUN jupyter nbextensions_configurator enable && \
264-
jupyter contrib nbextension install && \
265-
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
266-
jupyter serverextension enable --py jupyterlab --sys-prefix && \
267-
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
268-
jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
269-
jupyter serverextension enable --py jupyter_lsp && \
270-
jupyter labextension install --no-build @jupyterlab/toc && \
271-
# jupyter nbextension enable --py tensorflow_model_analysis && \
272-
jupyter labextension install --no-build jupyterlab-nvdashboard && \
273-
jupyter lab build
73+
# Install Horovod, temporarily using CUDA stubs
74+
RUN HOROVOD_WITH_TENSORFLOW=1 HOROVOD_WITHOUT_PYTORCH=1 HOROVOD_WITHOUT_MXNET=1 \
75+
pip install --no-cache-dir horovod==0.19.5 && \
76+
ldconfig
27477

78+
RUN python3 -m pip install --no-cache-dir \
79+
mpi4py==3.0.3 \
80+
nni==1.6 \
81+
scikit-nni==0.2.1
27582

27683
# Install ipython kernelspec
27784
Run python3 -m ipykernel install --display-name "TensorFlow 1.13 on Python 3.6 (CPU, MKL)" && \

0 commit comments

Comments
 (0)