|
| 1 | +# Copyright (C) 2025 Intel Corporation |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# Most of this Dockerfile originates from https://github.com/intel/intel-extension-for-pytorch/blob/main/examples/cpu/llm/Dockerfile |
| 5 | + |
| 6 | +ARG BASE_IMAGE=ubuntu:22.04 |
| 7 | +FROM ${BASE_IMAGE} AS base |
| 8 | +RUN if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi && \ |
| 9 | + if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::Proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi && \ |
| 10 | + if [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::Proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi |
| 11 | +RUN apt update && \ |
| 12 | + apt full-upgrade -y && \ |
| 13 | + DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \ |
| 14 | + ca-certificates \ |
| 15 | + git \ |
| 16 | + curl \ |
| 17 | + wget \ |
| 18 | + vim \ |
| 19 | + numactl \ |
| 20 | + gcc-12 \ |
| 21 | + g++-12 \ |
| 22 | + make |
| 23 | +RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \ |
| 24 | + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \ |
| 25 | + update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 && \ |
| 26 | + update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 |
| 27 | + |
| 28 | +WORKDIR /root |
| 29 | + |
| 30 | +RUN curl -fsSL -v -o miniforge.sh -O https://github.com/conda-forge/miniforge/releases/download/24.7.1-2/Miniforge3-24.7.1-2-Linux-x86_64.sh && \ |
| 31 | + bash miniforge.sh -b -p ./miniforge3 && \ |
| 32 | + rm miniforge.sh |
| 33 | + |
| 34 | +# --build-arg COMPILE=ON to compile from source |
| 35 | +FROM base AS dev |
| 36 | +ARG COMPILE |
| 37 | +RUN git clone https://github.com/intel/intel-extension-for-pytorch.git |
| 38 | +RUN . ~/miniforge3/bin/activate && conda create -y -n compile_py310 python=3.10 && conda activate compile_py310 && \ |
| 39 | + cd intel-extension-for-pytorch/examples/cpu/llm && \ |
| 40 | + export CC=gcc && export CXX=g++ && \ |
| 41 | + if [ -z ${COMPILE} ]; then bash tools/env_setup.sh 14; else bash tools/env_setup.sh 10; fi && \ |
| 42 | + unset CC && unset CXX |
| 43 | + |
| 44 | +FROM base AS deploy |
| 45 | +RUN apt update && \ |
| 46 | + DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \ |
| 47 | + google-perftools \ |
| 48 | + openssh-server \ |
| 49 | + net-tools && \ |
| 50 | + apt clean && \ |
| 51 | + rm -rf /var/lib/apt/lists/* && \ |
| 52 | + if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi |
| 53 | +COPY --from=dev /root/intel-extension-for-pytorch/examples/cpu/llm ./llm |
| 54 | +COPY --from=dev /root/intel-extension-for-pytorch/tools/get_libstdcpp_lib.sh ./llm/tools |
| 55 | +RUN . ~/miniforge3/bin/activate && conda create -y -n py310 python=3.10 && conda activate py310 && \ |
| 56 | + cd /usr/lib/x86_64-linux-gnu/ && ln -s libtcmalloc.so.4 libtcmalloc.so && cd && \ |
| 57 | + cd ./llm && \ |
| 58 | + bash tools/env_setup.sh 9 && \ |
| 59 | + python -m pip cache purge && \ |
| 60 | + mv ./oneCCL_release /opt/oneCCL && \ |
| 61 | + chown -R root:root /opt/oneCCL && \ |
| 62 | + sed -i "s|ONECCL_PATH=.*|ONECCL_PATH=/opt/oneCCL|" ./tools/env_activate.sh && \ |
| 63 | + pip install backoff fastapi uvicorn |
| 64 | +ARG PORT_SSH=22 |
| 65 | +RUN mkdir /var/run/sshd && \ |
| 66 | + sed -i "s/#Port.*/Port ${PORT_SSH}/" /etc/ssh/sshd_config && \ |
| 67 | + echo "service ssh start" >> /root/.bashrc && \ |
| 68 | + ssh-keygen -b 4096 -f /root/.ssh/id_rsa -N "" && \ |
| 69 | + mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \ |
| 70 | + echo "Host *\n Port ${PORT_SSH}\n IdentityFile /root/.ssh/id_rsa\n StrictHostKeyChecking no" > /root/.ssh/config |
| 71 | +EXPOSE ${PORT_SSH} |
| 72 | +COPY ./comps/third_parties/ipex/src/ipex_inference.py /root |
| 73 | +COPY ./comps/third_parties/ipex/src/openai_protocol.py /root |
| 74 | +COPY ./comps/third_parties/ipex/src/entrypoint.sh /usr/local/bin/entrypoint.sh |
| 75 | +RUN chmod +x /usr/local/bin/entrypoint.sh |
| 76 | +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
| 77 | + |
0 commit comments