forked from intel/intel-extension-for-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
74 lines (70 loc) · 3.31 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
# NOTE: To build this you will need a docker version >= 19.03 and DOCKER_BUILDKIT=1
#
# If you do not use buildkit you are not going to have a good time
#
# For reference:
# https://docs.docker.com/develop/develop-images/build_enhancements/
ARG BASE_IMAGE=ubuntu:22.04
FROM ${BASE_IMAGE} AS base
RUN if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi && \
if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::Proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi && \
if [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::Proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi
RUN apt update && \
apt full-upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
ca-certificates \
git \
curl \
wget \
vim \
python3 \
python3-dev \
python3-pip \
numactl \
gcc-12 \
g++-12 \
make \
cmake
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 100
WORKDIR /root
ENV PATH=/root/.local/bin:${PATH}
# --build-arg COMPILE=ON to compile from source
FROM base AS dev
ARG COMPILE
COPY . ./intel-extension-for-pytorch
RUN cd intel-extension-for-pytorch/examples/cpu/inference/python/llm && \
export CC=gcc && export CXX=g++ && \
if [ -z ${COMPILE} ]; then bash tools/env_setup.sh 6; else bash tools/env_setup.sh 2; fi && \
unset CC && unset CXX
FROM base AS deploy
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
google-perftools \
openssh-server \
net-tools && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi
COPY --from=dev /root/intel-extension-for-pytorch/examples/cpu/inference/python/llm ./llm
COPY --from=dev /root/intel-extension-for-pytorch/tools/get_libstdcpp_lib.sh ./llm/tools
RUN cd /usr/lib/x86_64-linux-gnu/ && ln -s libtcmalloc.so.4 libtcmalloc.so && cd && \
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ./.bashrc && \
cd ./llm && \
bash tools/env_setup.sh 1 && \
python -m pip cache purge && \
mv ./oneCCL_release /opt/oneCCL && \
chown -R root:root /opt/oneCCL && \
sed -i "s|ONECCL_PATH=.*|ONECCL_PATH=/opt/oneCCL|" ./tools/env_activate.sh && \
LN=$(grep "Conda environment is not available." -n ./tools/env_activate.sh | cut -d ":" -f 1) && sed -i "${LN}s|.*| export LD_PRELOAD=\${LD_PRELOAD}:/usr/lib/x86_64-linux-gnu/libtcmalloc.so:/usr/local/lib/libiomp5.so|" ./tools/env_activate.sh
ARG PORT_SSH=22
RUN mkdir /var/run/sshd && \
sed -i "s/#Port.*/Port ${PORT_SSH}/" /etc/ssh/sshd_config && \
echo "service ssh start" >> /root/.bashrc && \
ssh-keygen -b 4096 -f /root/.ssh/id_rsa -N "" && \
mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
echo "Host *\n Port ${PORT_SSH}\n IdentityFile /root/.ssh/id_rsa\n StrictHostKeyChecking no" > /root/.ssh/config
EXPOSE ${PORT_SSH}