|
| 1 | +# Copyright 2026 The TensorFlow Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# ============================================================================ |
| 15 | +# |
| 16 | +# |
| 17 | +# This file was assembled from multiple pieces, whose use is documented |
| 18 | +# throughout. Please refer to the TensorFlow dockerfiles documentation |
| 19 | +# for more information. |
| 20 | + |
| 21 | +ARG PACKAGE_OPTION=pip |
| 22 | +ARG MPI=openmpi |
| 23 | + |
| 24 | +ARG COMPOSE_PROJECT_NAME |
| 25 | +FROM ${COMPOSE_PROJECT_NAME}-python AS tf-base-pip |
| 26 | + |
| 27 | +# Intel Optimizations specific Envs |
| 28 | +ENV KMP_AFFINITY='granularity=fine,verbose,compact,1,0' \ |
| 29 | + KMP_BLOCKTIME=1 \ |
| 30 | + KMP_SETTINGS=1 |
| 31 | + |
| 32 | +ARG TF_PACKAGE |
| 33 | +ARG TF_PACKAGE_VERSION |
| 34 | + |
| 35 | +RUN python -m pip install --no-cache-dir ${TF_PACKAGE}${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}} \ |
| 36 | + tensorflow_hub \ |
| 37 | + Pillow \ |
| 38 | + cryptography==41.0.3 |
| 39 | + |
| 40 | +# Add Intel TF Licensing |
| 41 | +RUN mkdir /licensing && \ |
| 42 | + wget -O - https://github.com/Intel-tensorflow/tensorflow/archive/v${TF_PACKAGE_VERSION}.tar.gz | \ |
| 43 | + tar -xz -C /licensing --strip=2 "tensorflow-${TF_PACKAGE_VERSION}/third_party_programs_license/" && \ |
| 44 | + curl --insecure https://raw.githubusercontent.com/Intel-tensorflow/tensorflow/v${TF_PACKAGE_VERSION}/LICENSE -o /licensing/TF_LICENSE |
| 45 | + |
| 46 | +FROM ${COMPOSE_PROJECT_NAME}-python AS tf-base-idp |
| 47 | + |
| 48 | +# Intel Optimizations specific Envs |
| 49 | +ENV KMP_AFFINITY='granularity=fine,verbose,compact,1,0' \ |
| 50 | + KMP_BLOCKTIME=1 \ |
| 51 | + KMP_SETTINGS=1 |
| 52 | + |
| 53 | +ENV PATH /usr/bin:/root/conda/envs/idp/bin:/root/conda/condabin:~/conda/bin/:${PATH} |
| 54 | + |
| 55 | +ENV TF_ENABLE_ONEDNN_OPTS=1 |
| 56 | +ARG TF_PACKAGE |
| 57 | +ARG TF_PACKAGE_VERSION |
| 58 | + |
| 59 | +RUN python -m pip install --no-cache-dir ${TF_PACKAGE}${TF_PACKAGE_VERSION:+==${TF_PACKAGE_VERSION}} \ |
| 60 | + tensorflow_hub \ |
| 61 | + Pillow \ |
| 62 | + certifi==2023.7.22 \ |
| 63 | + cryptography==41.0.3 \ |
| 64 | + scipy==1.11.1 |
| 65 | + |
| 66 | +# Add Intel TF Licensing |
| 67 | +RUN mkdir /licensing && \ |
| 68 | + wget -O - https://github.com/Intel-tensorflow/tensorflow/archive/v${TF_PACKAGE_VERSION}.tar.gz | \ |
| 69 | + tar -xz -C /licensing --strip=2 "tensorflow-${TF_PACKAGE_VERSION}/third_party_programs_license/" && \ |
| 70 | + curl --insecure https://raw.githubusercontent.com/Intel-tensorflow/tensorflow/v${TF_PACKAGE_VERSION}/LICENSE -o /licensing/TF_LICENSE |
| 71 | + |
| 72 | +FROM tf-base-${PACKAGE_OPTION} AS jupyter |
| 73 | + |
| 74 | +RUN python -m pip install --no-cache-dir jupyterlab jupyterhub notebook jupyter-server-proxy |
| 75 | + |
| 76 | +RUN mkdir -p /jupyter/ && chmod -R a+rwx /jupyter/ |
| 77 | +RUN mkdir /.local && chmod a+rwx /.local |
| 78 | +WORKDIR /jupyter |
| 79 | + |
| 80 | +ARG PORT=8888 |
| 81 | +EXPOSE $PORT |
| 82 | + |
| 83 | +CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/jupyter --port $PORT --ip 0.0.0.0 --no-browser --allow-root"] |
| 84 | + |
| 85 | +FROM tf-base-${PACKAGE_OPTION} AS mlflow |
| 86 | + |
| 87 | +RUN python -m pip install --no-cache-dir mlflow |
| 88 | + |
| 89 | +ARG PORT=5000 |
| 90 | +EXPOSE $PORT |
| 91 | + |
| 92 | +CMD ["mlflow", "server", "-h", "0.0.0.0", "-p", $PORT] |
| 93 | + |
| 94 | +FROM tf-base-${PACKAGE_OPTION} AS openmpi |
| 95 | + |
| 96 | +RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ |
| 97 | + libopenmpi-dev \ |
| 98 | + openmpi-bin \ |
| 99 | + openmpi-common |
| 100 | + |
| 101 | +FROM tf-base-${PACKAGE_OPTION} AS mpich |
| 102 | + |
| 103 | +RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ |
| 104 | + mpich \ |
| 105 | + libmpich-dev |
| 106 | + |
| 107 | +RUN python -m pip install --no-cache-dir impi-rt |
| 108 | + |
| 109 | +FROM ${MPI} AS horovod |
| 110 | + |
| 111 | +ENV LD_LIBRARY_PATH /lib64/:/usr/lib64/:/usr/local/lib64 |
| 112 | + |
| 113 | +RUN apt-get install -y --no-install-recommends --fix-missing \ |
| 114 | + openssh-client \ |
| 115 | + openssh-server && \ |
| 116 | + rm /etc/ssh/ssh_host_*_key \ |
| 117 | + /etc/ssh/ssh_host_*_key.pub |
| 118 | + |
| 119 | +ENV OMPI_ALLOW_RUN_AS_ROOT=1 |
| 120 | +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 |
| 121 | + |
| 122 | +ENV OMPI_MCA_tl_tcp_if_exclude="lo,docker0" |
| 123 | + |
| 124 | +# Install OpenSSH for MPI to communicate between containers |
| 125 | +RUN mkdir -p /var/run/sshd |
| 126 | + |
| 127 | +# Install Horovod |
| 128 | +ARG HOROVOD_VERSION |
| 129 | +ARG HOROVOD_WITH_TENSORFLOW=1 |
| 130 | +ARG HOROVOD_WITHOUT_MXNET=1 |
| 131 | +ARG HOROVOD_WITHOUT_PYTORCH=1 |
| 132 | +ARG HOROVOD_WITHOUT_GLOO=1 |
| 133 | +ARG HOROVOD_WITH_MPI=1 |
| 134 | + |
| 135 | +RUN apt-get install -y --no-install-recommends --fix-missing \ |
| 136 | + build-essential \ |
| 137 | + cmake \ |
| 138 | + g++ \ |
| 139 | + gcc \ |
| 140 | + git \ |
| 141 | + libgl1-mesa-glx \ |
| 142 | + libglib2.0-0 \ |
| 143 | + python3-dev && \ |
| 144 | + apt-get clean && \ |
| 145 | + rm -rf /var/lib/apt/lists/* |
| 146 | + |
| 147 | +RUN python -m pip install --no-cache-dir horovod${HOROVOD_VERSION+==${HOROVOD_VERSION}} |
| 148 | + |
| 149 | +ARG INC_VER |
| 150 | + |
| 151 | +ENV SIGOPT_PROJECT=. |
| 152 | + |
| 153 | +RUN curl --insecure https://raw.githubusercontent.com/intel/neural-compressor/master/docker/third-party-programs-tensorflow.txt -o /licensing/third-party-programs-tensorflow.txt && \ |
| 154 | + curl --insecure https://raw.githubusercontent.com/intel/neural-compressor/master/LICENSE -o /licensing/LICENSE |
| 155 | + |
| 156 | +FROM horovod AS multinode-pip |
| 157 | + |
| 158 | +RUN python -m pip install --no-cache-dir neural-compressor${INC_VER:+==${INC_VER}} \ |
| 159 | + tf2onnx |
| 160 | + |
| 161 | +FROM horovod AS multinode-idp |
| 162 | + |
| 163 | +RUN python -m pip install --no-cache-dir neural-compressor${INC_VER:+==${INC_VER}} \ |
| 164 | + cython \ |
| 165 | + tf2onnx |
| 166 | + |
| 167 | +FROM ${COMPOSE_PROJECT_NAME}-python AS itex-xpu-base |
| 168 | + |
| 169 | +RUN apt-get update && \ |
| 170 | + apt-get install -y --no-install-recommends --fix-missing \ |
| 171 | + apt-utils \ |
| 172 | + build-essential \ |
| 173 | + clinfo \ |
| 174 | + curl \ |
| 175 | + git \ |
| 176 | + gnupg2 \ |
| 177 | + gpg-agent \ |
| 178 | + rsync \ |
| 179 | + unzip \ |
| 180 | + wget && \ |
| 181 | + apt-get clean && \ |
| 182 | + rm -rf /var/lib/apt/lists/* |
| 183 | + |
| 184 | +ARG ICD_VER |
| 185 | +ARG LEVEL_ZERO_GPU_VER |
| 186 | +ARG LEVEL_ZERO_VER |
| 187 | +ARG LEVEL_ZERO_DEV_VER |
| 188 | +ARG DPCPP_VER |
| 189 | +ARG MKL_VER |
| 190 | +ARG CCL_VER |
| 191 | + |
| 192 | +RUN wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | \ |
| 193 | + gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg |
| 194 | +RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu jammy max" | \ |
| 195 | + tee /etc/apt/sources.list.d/intel-gpu-jammy.list |
| 196 | + |
| 197 | +RUN apt-get update && \ |
| 198 | + apt-get install -y --no-install-recommends --fix-missing \ |
| 199 | + intel-opencl-icd=${ICD_VER} \ |
| 200 | + intel-level-zero-gpu=${LEVEL_ZERO_GPU_VER} \ |
| 201 | + level-zero=${LEVEL_ZERO_VER} \ |
| 202 | + level-zero-dev=${LEVEL_ZERO_DEV_VER} && \ |
| 203 | + apt-get clean && \ |
| 204 | + rm -rf /var/lib/apt/lists/* |
| 205 | + |
| 206 | +RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ |
| 207 | + | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ |
| 208 | + echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ |
| 209 | + | tee /etc/apt/sources.list.d/oneAPI.list |
| 210 | + |
| 211 | +ARG DPCPP_VER |
| 212 | +ARG MKL_VER |
| 213 | +ARG CCL_VER |
| 214 | + |
| 215 | +RUN apt-get update && \ |
| 216 | + apt-get install -y --no-install-recommends --fix-missing \ |
| 217 | + intel-oneapi-runtime-dpcpp-cpp=${DPCPP_VER} \ |
| 218 | + intel-oneapi-runtime-mkl=${MKL_VER} \ |
| 219 | + intel-oneapi-runtime-ccl=${CCL_VER} && \ |
| 220 | + apt-get clean && \ |
| 221 | + rm -rf /var/lib/apt/lists/* |
| 222 | + |
| 223 | +ARG TF_VER="2.13" |
| 224 | + |
| 225 | +RUN python -m pip --no-cache-dir install tensorflow==${TF_VER} |
| 226 | + |
| 227 | +RUN python -m pip --no-cache-dir install --upgrade intel-extension-for-tensorflow[xpu] |
| 228 | + |
| 229 | +ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/THIRD-PARTY-PROGRAMS.txt /licenses/ |
| 230 | +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/ |
| 231 | +ADD https://raw.githubusercontent.com/intel/intel-extension-for-tensorflow/master/third-party-programs/dockerlayer/third-party-programs-of-intel-tensorflow.txt /licenses/ |
| 232 | +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/ |
| 233 | + |
| 234 | +FROM itex-xpu-base AS itex-xpu-jupyter |
| 235 | + |
| 236 | +RUN python -m pip install --no-cache-dir jupyterlab jupyterhub notebook jupyter-server-proxy |
| 237 | + |
| 238 | +RUN mkdir -p /jupyter/ && chmod -R a+rwx /jupyter/ |
| 239 | +RUN mkdir /.local && chmod a+rwx /.local |
| 240 | +WORKDIR /jupyter |
| 241 | +COPY notebooks/itex/itex-xpu.ipynb /jupyter/xpu.ipynb |
| 242 | + |
| 243 | +ARG PORT=8888 |
| 244 | +EXPOSE $PORT |
| 245 | + |
| 246 | +CMD ["bash", "-c", "jupyter notebook --notebook-dir=/jupyter --port $PORT --ip 0.0.0.0 --no-browser --allow-root"] |
0 commit comments