1
- # Lablup/Python-TensorFlow 1.13 Python 3.6
1
+ FROM ubuntu:18.04
2
+
3
+
4
+ # These parameters can be overridden by parameterized_docker_build.sh
5
+ 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
+
149
+
150
+ # Set up Bazel.
151
+
152
+ # Running bazel inside a `docker build` command causes trouble, cf:
153
+ # https://github.com/bazelbuild/bazel/issues/134
154
+ # The easiest solution is to set up a bazelrc file forcing --batch.
155
+ RUN echo "startup --batch" >>/etc/bazel.bazelrc
156
+ # Similarly, we need to workaround sandboxing issues:
157
+ # https://github.com/bazelbuild/bazel/issues/418
158
+ RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
159
+ >>/etc/bazel.bazelrc
160
+ # Install the most recent bazel release.
161
+ ENV BAZEL_VERSION 0.20.0
162
+ WORKDIR /
163
+ RUN mkdir /bazel && \
164
+ cd /bazel && \
165
+ curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
166
+ curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
167
+ chmod +x bazel-*.sh && \
168
+ ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
169
+ cd / && \
170
+ rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
171
+
172
+ # Download and build TensorFlow.
173
+ WORKDIR /tensorflow
174
+
175
+ # Download and build TensorFlow.
176
+ # Enable checking out both tags and branches
177
+ RUN export TAG_PREFIX="v" && \
178
+ echo ${TF_BUILD_VERSION} | grep -q ^${TAG_PREFIX}; \
179
+ if [ $? -eq 0 ]; then \
180
+ git clone --depth=1 https://github.com/tensorflow/tensorflow.git . && \
181
+ git fetch --tags && \
182
+ git checkout ${TF_BUILD_VERSION}; \
183
+ else \
184
+ git clone --depth=1 --branch=${TF_BUILD_VERSION} https://github.com/tensorflow/tensorflow.git . ; \
185
+ fi
186
+
187
+ RUN yes "" | ${PYTHON} configure.py
188
+ RUN cp .bazelrc /root/.bazelrc
189
+
190
+ ENV CI_BUILD_PYTHON ${PYTHON}
191
+ ENV WHL_DIR=/tmp/pip3
192
+ # Set bazel build parameters in .bazelrc in parameterized_docker_build.sh
193
+ # Use --copt=-march values to get optimized builds appropriate for the hardware
194
+ # platform of your choice.
195
+ # For ivy-bridge or sandy-bridge
196
+ # --copt=-march="avx" \
197
+ # For haswell, broadwell, or skylake
198
+ # --copt=-march="avx2" \
199
+ COPY .bazelrc /root/.mkl.bazelrc
200
+ RUN echo "import /root/.mkl.bazelrc" >>/root/.bazelrc
201
+
202
+ RUN tensorflow/tools/ci_build/builds/configured CPU \
203
+ bazel --bazelrc=/root/.bazelrc build -c opt \
204
+ tensorflow/tools/pip_package:build_pip_package && \
205
+ bazel-bin/tensorflow/tools/pip_package/build_pip_package "${WHL_DIR}" && \
206
+ python3 -m pip --no-cache-dir install --upgrade "${WHL_DIR}" /tensorflow-*.whl && \
207
+ rm -rf /root/.cache
208
+ # Clean up Bazel cache when done.
209
+
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
2
274
3
- FROM lablup/common-tensorflow:1.13-py36 as tf-binary
4
- FROM lablup/common-base:19.06-py36
5
- MAINTAINER Mario Cho
"[email protected] "
6
275
7
276
# Install ipython kernelspec
8
- RUN python3 -m ipykernel install --display-name "TensorFlow 1.13 on Python 3.6 (CPU-only )" && \
277
+ Run python3 -m ipykernel install --display-name "TensorFlow 1.13 on Python 3.6 (CPU, MKL )" && \
9
278
cat /usr/local/share/jupyter/kernels/python3/kernel.json
10
279
11
- COPY --from=tf-binary /tmp/tensorflow_pkg/tensorflow-*.whl /tmp
12
-
13
- RUN python3 -m pip install --no-cache-dir wheel /tmp/*.whl && \
14
- python3 -m pip install --no-cache-dir keras && \
15
- python3 -m pip install --no-cache-dir keras_applications && \
16
- python3 -m pip install --no-cache-dir keras_preprocessing && \
17
- python3 -m pip install --no-cache-dir tensorflow-hub==0.5.0 && \
18
- python3 -m pip install --no-cache-dir tf2onnx && \
19
- rm -rf /root/.cache && \
20
- rm -f /tmp/*.whl
21
-
22
- # for apt-get installation using /tmp
23
- RUN mkdir -p /tmp && \
24
- chown root:root /tmp && \
25
- chmod 1777 /tmp
26
-
27
280
# Backend.AI specifics
28
281
LABEL ai.backend.kernelspec="1" \
29
282
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
30
283
ai.backend.features="batch query uid-match user-input" \
31
284
ai.backend.base-distro="ubuntu16.04" \
32
285
ai.backend.resource.min.cpu="1" \
33
286
ai.backend.resource.min.mem="1g" \
287
+ ai.backend.resource.min.cuda.device=0 \
288
+ ai.backend.resource.min.cuda.shares=0 \
34
289
ai.backend.runtime-type="python" \
35
- ai.backend.runtime-path="/usr/local/ bin/python " \
36
- ai.backend.service-ports="ipython:pty:3000,jupyter:http:8080,jupyterlab:http:8090"
290
+ ai.backend.runtime-path="/usr/bin/python3 " \
291
+ ai.backend.service-ports="ipython:pty:3000,jupyter:http:8080,jupyterlab:http:8090,vscode:http:8180,tensorboard:http:6006 "
37
292
38
293
WORKDIR /home/work
39
294
# vim: ft=dockerfile
0 commit comments