-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile
282 lines (215 loc) · 10.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# 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.
# ============================================================================
#
#
# This file was assembled from multiple pieces, whose use is documented
# throughout. Please refer to the TensorFlow dockerfiles documentation
# for more information.
ARG REGISTRY
ARG REPO
ARG GITHUB_RUN_NUMBER
ARG BASE_IMAGE_NAME
ARG BASE_IMAGE_TAG
ARG PACKAGE_OPTION=pip
ARG PYTHON_VERSION
ARG PYTHON_BASE=${REGISTRY}/${REPO}:b-${GITHUB_RUN_NUMBER}-${BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${PACKAGE_OPTION}-py${PYTHON_VERSION}-base
FROM ${PYTHON_BASE} AS tf-base-pip
# Intel Optimizations specific Envs
ENV KMP_AFFINITY='granularity=fine,verbose,compact,1,0' \
KMP_BLOCKTIME=1 \
KMP_SETTINGS=1
ARG TF_VERSION
WORKDIR /
COPY requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/THIRD-PARTY-PROGRAMS.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-program-of-intel-extension-for-tensorflow.txt /licenses/
FROM ${PYTHON_BASE} AS tf-base-idp
# Intel Optimizations specific Envs
ENV KMP_AFFINITY='granularity=fine,verbose,compact,1,0' \
KMP_BLOCKTIME=1 \
KMP_SETTINGS=1
ENV PATH /usr/bin:/root/conda/envs/idp/bin:/root/conda/condabin:~/conda/bin/:${PATH}
ENV TF_ENABLE_ONEDNN_OPTS=1
ARG TF_VERSION
WORKDIR /
COPY requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/THIRD-PARTY-PROGRAMS.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-program-of-intel-extension-for-tensorflow.txt /licenses/
FROM tf-base-${PACKAGE_OPTION} AS jupyter
WORKDIR /jupyter
COPY jupyter-requirements.txt .
RUN python -m pip install --no-cache-dir -r jupyter-requirements.txt
RUN mkdir -p /jupyter/ && chmod -R a+rwx /jupyter/
RUN mkdir /.local && chmod a+rwx /.local
EXPOSE 8888
CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/jupyter --port 8888 --ip 0.0.0.0 --no-browser --allow-root --ServerApp.token= --ServerApp.password= --ServerApp.allow_origin=* --ServerApp.base_url=$NB_PREFIX"]
FROM tf-base-${PACKAGE_OPTION} AS openmpi
RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \
libopenmpi-dev \
openmpi-bin \
openmpi-common
WORKDIR /
COPY ompi-requirements.txt .
RUN python -m pip install --no-cache-dir -r ompi-requirements.txt
FROM openmpi AS horovod
ENV LD_LIBRARY_PATH /lib64/:/usr/lib64/:/usr/local/lib64
RUN apt-get install -y --no-install-recommends --fix-missing \
unzip \
openssh-client \
openssh-server && \
rm /etc/ssh/ssh_host_*_key \
/etc/ssh/ssh_host_*_key.pub
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
ENV OMPI_MCA_tl_tcp_if_exclude="lo,docker0"
# Install OpenSSH for MPI to communicate between containers
RUN mkdir -p /var/run/sshd && \
echo 'LoginGraceTime 0' >> /etc/ssh/sshd_config
# Install Horovod
ARG HOROVOD_WITH_TENSORFLOW=1
ARG HOROVOD_WITHOUT_MXNET=1
ARG HOROVOD_WITHOUT_PYTORCH=1
ARG HOROVOD_WITHOUT_GLOO=1
ARG HOROVOD_WITH_MPI=1
RUN apt-get install -y --no-install-recommends --fix-missing \
build-essential \
cmake \
g++ \
gcc \
git \
libgl1-mesa-glx \
libglib2.0-0 \
python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /
COPY hvd-requirements.txt .
RUN python -m pip install --no-cache-dir -r hvd-requirements.txt
ENV SIGOPT_PROJECT=.
RUN wget --progress=dot:giga --no-check-certificate https://github.com/intel/neural-compressor/raw/master/docker/third-party-programs-tensorflow.txt -O /licenses/inc-third-party-programs-tensorflow.txt && \
wget --progress=dot:giga --no-check-certificate https://raw.githubusercontent.com/intel/neural-compressor/master/LICENSE -O /licenses/INC_LICENSE
FROM horovod AS multinode-pip
WORKDIR /
COPY multinode-requirements.txt .
RUN python -m pip install --no-cache-dir -r multinode-requirements.txt
FROM horovod AS multinode-idp
WORKDIR /
COPY multinode-requirements.txt .
RUN python -m pip install --no-cache-dir -r multinode-requirements.txt
FROM ${PYTHON_BASE} AS itex-xpu-base-pip
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
apt-utils \
build-essential \
clinfo \
git \
gnupg2 \
gpg-agent \
rsync \
unzip \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ARG ICD_VER
ARG LEVEL_ZERO_GPU_VER
ARG LEVEL_ZERO_VER
ARG LEVEL_ZERO_DEV_VER
ARG DPCPP_VER
ARG MKL_VER
ARG CCL_VER
RUN no_proxy="" NO_PROXY="" wget --no-check-certificate -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy/lts/2350 unified" | \
tee /etc/apt/sources.list.d/intel-gpu-jammy.list
RUN no_proxy="" NO_PROXY="" apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
intel-opencl-icd=${ICD_VER} \
intel-level-zero-gpu=${LEVEL_ZERO_GPU_VER} \
level-zero=${LEVEL_ZERO_VER} \
level-zero-dev=${LEVEL_ZERO_DEV_VER} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN no_proxy="" NO_PROXY="" wget --progress=dot:giga -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
| tee /etc/apt/sources.list.d/oneAPI.list
ARG DPCPP_VER
ARG MKL_VER
ARG CCL_VER
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
intel-oneapi-runtime-dpcpp-cpp=${DPCPP_VER} \
intel-oneapi-runtime-mkl=${MKL_VER} \
intel-oneapi-runtime-ccl=${CCL_VER} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /
COPY xpu-requirements.txt .
RUN python -m pip --no-cache-dir install -r xpu-requirements.txt
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/THIRD-PARTY-PROGRAMS.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-program-of-intel-extension-for-tensorflow.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-programs-of-intel-tensorflow.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-programs-of-intel-optimization-for-horovod.txt /licenses/
ENV LD_LIBRARY_PATH=/opt/intel/oneapi/redist/lib:$LD_LIBRARY_PATH
FROM ${PYTHON_BASE} AS itex-xpu-base-idp
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
apt-utils \
build-essential \
clinfo \
git \
gnupg2 \
gpg-agent \
rsync \
unzip \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ARG ICD_VER
ARG LEVEL_ZERO_GPU_VER
ARG LEVEL_ZERO_VER
ARG LEVEL_ZERO_DEV_VER
RUN no_proxy="" NO_PROXY="" wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy/lts/2350 unified" | \
tee /etc/apt/sources.list.d/intel-gpu-jammy.list
RUN no_proxy="" NO_PROXY="" apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
intel-opencl-icd=${ICD_VER} \
intel-level-zero-gpu=${LEVEL_ZERO_GPU_VER} \
level-zero=${LEVEL_ZERO_VER} \
level-zero-dev=${LEVEL_ZERO_DEV_VER} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ARG TF_VER="2.15.0"
RUN conda install intel-extension-for-tensorflow=${TF_VER}=*xpu* \
-c https://software.repos.intel.com/python/conda \
-c conda-forge
ENV LD_LIBRARY_PATH=/opt/conda/envs/idp/lib:$LD_LIBRARY_PATH
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/THIRD-PARTY-PROGRAMS.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-program-of-intel-extension-for-tensorflow.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-programs-of-intel-tensorflow.txt /licenses/
ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-programs-of-intel-optimization-for-horovod.txt /licenses/
FROM itex-xpu-base-${PACKAGE_OPTION} AS itex-xpu-jupyter
WORKDIR /jupyter
COPY jupyter-requirements.txt .
RUN python -m pip install --no-cache-dir -r jupyter-requirements.txt
RUN mkdir -p /jupyter/ && chmod -R a+rwx /jupyter/
RUN mkdir /.local && chmod a+rwx /.local
COPY notebooks/itex/itex-xpu.ipynb /jupyter/xpu.ipynb
EXPOSE 8888
CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/jupyter --port 8888 --ip 0.0.0.0 --no-browser --allow-root --ServerApp.token= --ServerApp.password= --ServerApp.allow_origin=* --ServerApp.base_url=$NB_PREFIX"]