Skip to content

Commit 64ba751

Browse files
jingxu10chunyuan-w
andauthored
update dockerfiles and compile bundle script for 2.5 release (#3338)
* add torch-ccl installation to dockerfile.compile (#3332) * update dockerfiles and compile bundle script * add numactl back --------- Co-authored-by: Chunyuan WU <[email protected]>
1 parent b8c2371 commit 64ba751

File tree

6 files changed

+122
-59
lines changed

6 files changed

+122
-59
lines changed

dependency_version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"version": "2.5.0+cpu"
2121
},
2222
"deepspeed": {
23-
"version": "0.15.2",
24-
"commit": "v0.15.2"
23+
"version": "",
24+
"commit": "e06bb518aa7dafef1e98a1da63362e1586b2ddd5"
2525
},
2626
"oneCCL": {
2727
"commit": "2021.12"
2828
},
2929
"lm-evaluation-harness": {
3030
"commit": "cc9778fbe4fa1a709be2abed9deb6180fd40e7e2"
3131
}
32-
}
32+
}

docker/Dockerfile.compile

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,32 @@ RUN apt update && \
2222
wget \
2323
vim \
2424
numactl \
25+
google-perftools \
26+
openssh-server \
27+
net-tools \
2528
gcc-12 \
2629
g++-12 \
27-
python3 \
28-
python3-dev \
29-
python3-pip \
3030
make
31-
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
32-
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
33-
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 && \
34-
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 && \
35-
update-alternatives --install /usr/bin/python python /usr/bin/python3 100
3631
RUN apt clean && \
3732
rm -rf /var/lib/apt/lists/* && \
3833
if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi
34+
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
35+
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
36+
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 && \
37+
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
3938

4039
WORKDIR /root
41-
ENV PATH=/root/.local/bin:${PATH}
40+
41+
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 && \
42+
bash miniforge.sh -b -p ./miniforge3 && \
43+
rm miniforge.sh
4244

4345
FROM base AS dev
4446
COPY . ./intel-extension-for-pytorch
4547
RUN cp ./intel-extension-for-pytorch/scripts/compile_bundle.sh ./ && \
4648
sed -i "s/VER_IPEX=.*/VER_IPEX=/" compile_bundle.sh
47-
RUN CC=gcc CXX=g++ bash compile_bundle.sh && \
49+
RUN . ~/miniforge3/bin/activate && conda create -y -n compile_py310 python=3.10 && conda activate compile_py310 && \
50+
CC=gcc CXX=g++ bash compile_bundle.sh && \
4851
cd intel-extension-for-pytorch && \
4952
VER_TORCH=$(python tools/dep_ver_utils.py -f dependency_version.json -k pytorch:version) && \
5053
VER_TORCHVISION=$(python tools/dep_ver_utils.py -f dependency_version.json -k torchvision:version) && \
@@ -53,11 +56,33 @@ RUN CC=gcc CXX=g++ bash compile_bundle.sh && \
5356
echo ${VER_TORCH} | grep "dev" > /dev/null; TORCH_DEV=$?; URL_NIGHTLY=""; if [ ${TORCH_DEV} -eq 0 ]; then URL_NIGHTLY="nightly/"; fi; echo "#!/bin/bash\npython -m pip install torch==${VER_TORCH} torchvision==${VER_TORCHVISION} torchaudio==${VER_TORCHAUDIO} --index-url https://download.pytorch.org/whl/${URL_NIGHTLY}cpu" > torch_install.sh
5457

5558
FROM base AS deploy
56-
COPY --from=dev /root/intel-extension-for-pytorch/dist ./wheels
59+
COPY --from=dev /root/intel-extension-for-pytorch/dist ./wheels/
60+
COPY --from=dev /root/torch-ccl/dist ./wheels/
5761
COPY --from=dev /root/torch_install.sh .
58-
RUN bash ./torch_install.sh && rm ./torch_install.sh && \
62+
RUN cd /usr/lib/x86_64-linux-gnu/ && ln -s libtcmalloc.so.4 libtcmalloc.so && cd && \
63+
. ~/miniforge3/bin/activate && conda create -y -n py310 python=3.10 && conda activate py310 && \
64+
bash ./torch_install.sh && rm ./torch_install.sh && \
5965
python -m pip install ./wheels/*.whl && \
60-
python -m pip install intel-openmp==2024.1.2 && \
66+
python -m pip install intel-openmp && \
6167
python -m pip cache purge && \
62-
rm -rf ./wheels && \
63-
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ./.bashrc
68+
rm -rf ./wheels
69+
ARG PORT_SSH=22
70+
RUN mkdir /var/run/sshd && \
71+
sed -i "s/#Port.*/Port ${PORT_SSH}/" /etc/ssh/sshd_config && \
72+
echo "service ssh start" >> /root/.bashrc && \
73+
ssh-keygen -b 4096 -f /root/.ssh/id_rsa -N "" && \
74+
mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
75+
echo "Host *\n Port ${PORT_SSH}\n IdentityFile /root/.ssh/id_rsa\n StrictHostKeyChecking no" > /root/.ssh/config
76+
EXPOSE ${PORT_SSH}
77+
RUN ENTRYPOINT=/usr/local/bin/entrypoint.sh && \
78+
echo "#!/bin/bash" > ${ENTRYPOINT} && \
79+
echo "CMDS=(); while [ \$# -gt 0 ]; do CMDS+=(\$1); shift; done;" >> ${ENTRYPOINT} && \
80+
echo "CMD=\"\"; for i in \${!CMDS[@]}; do CMD=\"\${CMD} \${CMDS[\$i]}\"; done;" >> ${ENTRYPOINT} && \
81+
echo ". ~/miniforge3/bin/activate" >> ${ENTRYPOINT} && \
82+
echo "conda activate py310" >> ${ENTRYPOINT} && \
83+
echo "TMP=\$(python -c \"import torch; import os; print(os.path.abspath(os.path.dirname(torch.__file__)))\")" >> ${ENTRYPOINT} && \
84+
echo ". \${TMP}/../oneccl_bindings_for_pytorch/env/setvars.sh" >> ${ENTRYPOINT} && \
85+
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ${ENTRYPOINT} && \
86+
echo "exec \${CMD}" >> ${ENTRYPOINT} && \
87+
chmod +x ${ENTRYPOINT}
88+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

docker/Dockerfile.prebuilt

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,60 @@ FROM ubuntu:${UBUNTU_VERSION}
1414

1515
# See http://bugs.python.org/issue19846
1616
ENV LANG C.UTF-8
17-
ARG PYTHON=python3
1817

19-
RUN apt-get update -y && \
20-
apt-get upgrade -y && \
21-
apt-get install -y --no-install-recommends --fix-missing \
22-
${PYTHON} \
23-
${PYTHON}-pip \
24-
${PYTHON}-dev
18+
RUN if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi && \
19+
if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::Proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi && \
20+
if [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::Proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf.d/proxy.conf; fi
21+
RUN apt update -y && \
22+
apt full-upgrade -y && \
23+
DEBIAN_FRONTEND=noninteractive apt install -y \
24+
python3 \
25+
python3-pip \
26+
python3-dev \
27+
python3-venv \
28+
google-perftools \
29+
openssh-server \
30+
net-tools
31+
RUN apt clean && \
32+
rm -rf /var/lib/apt/lists/* && \
33+
if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi
34+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 100
2535

26-
RUN ${PYTHON} -m pip --no-cache-dir install --upgrade \
36+
WORKDIR /root
37+
38+
ARG IPEX_VERSION=2.5.0
39+
ARG TORCHCCL_VERSION=2.5.0
40+
ARG PYTORCH_VERSION=2.5.0
41+
ARG TORCHAUDIO_VERSION=2.5.0
42+
ARG TORCHVISION_VERSION=0.20.0
43+
RUN . ./venv/bin/activate && \
44+
python -m pip --no-cache-dir install --upgrade \
2745
pip \
2846
setuptools \
29-
psutil
30-
31-
# Some TF tools expect a "python" binary
32-
RUN ln -s $(which ${PYTHON}) /usr/local/bin/python
33-
34-
ARG IPEX_VERSION=2.4.00
35-
ARG PYTORCH_VERSION=2.4.0
36-
ARG TORCHAUDIO_VERSION=2.4.0
37-
ARG TORCHVISION_VERSION=0.19.0
38-
ARG TORCH_CPU_URL=https://download.pytorch.org/whl/cpu/torch_stable.html
39-
40-
RUN \
47+
psutil && \
4148
python -m pip install --no-cache-dir \
42-
torch==${PYTORCH_VERSION}+cpu torchvision==${TORCHVISION_VERSION}+cpu torchaudio==${TORCHAUDIO_VERSION}+cpu -f ${TORCH_CPU_URL} && \
49+
torch==${PYTORCH_VERSION}+cpu torchvision==${TORCHVISION_VERSION}+cpu torchaudio==${TORCHAUDIO_VERSION}+cpu --index-url https://download.pytorch.org/whl/cpu && \
4350
python -m pip install --no-cache-dir \
44-
intel_extension_for_pytorch==${IPEX_VERSION}
51+
intel_extension_for_pytorch==${IPEX_VERSION} oneccl_bind_pt==${TORCHCCL_VERSION} --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/ && \
52+
python -m pip install intel-openmp && \
53+
python -m pip cache purge
4554

46-
RUN useradd -m ubuntu
47-
RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
48-
USER ubuntu
49-
WORKDIR /home/ubuntu
55+
ARG PORT_SSH=22
56+
RUN mkdir /var/run/sshd && \
57+
sed -i "s/#Port.*/Port ${PORT_SSH}/" /etc/ssh/sshd_config && \
58+
echo "service ssh start" >> /root/.bashrc && \
59+
ssh-keygen -b 4096 -f /root/.ssh/id_rsa -N "" && \
60+
mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
61+
echo "Host *\n Port ${PORT_SSH}\n IdentityFile /root/.ssh/id_rsa\n StrictHostKeyChecking no" > /root/.ssh/config
62+
EXPOSE ${PORT_SSH}
63+
RUN ENTRYPOINT=/usr/local/bin/entrypoint.sh && \
64+
echo "#!/bin/bash" > ${ENTRYPOINT} && \
65+
echo "CMDS=(); while [ \$# -gt 0 ]; do CMDS+=(\$1); shift; done;" >> ${ENTRYPOINT} && \
66+
echo "CMD=\"\"; for i in \${!CMDS[@]}; do CMD=\"\${CMD} \${CMDS[\$i]}\"; done;" >> ${ENTRYPOINT} && \
67+
echo ". ~/venv/bin/activate" >> ${ENTRYPOINT} && \
68+
echo "TMP=\$(python -c \"import torch; import os; print(os.path.abspath(os.path.dirname(torch.__file__)))\")" >> ${ENTRYPOINT} && \
69+
echo ". \${TMP}/../oneccl_bindings_for_pytorch/env/setvars.sh" >> ${ENTRYPOINT} && \
70+
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ${ENTRYPOINT} && \
71+
echo "exec \${CMD}" >> ${ENTRYPOINT} && \
72+
chmod +x ${ENTRYPOINT}
73+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

examples/cpu/llm/Dockerfile

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,27 @@ RUN apt update && \
2121
curl \
2222
wget \
2323
vim \
24-
python3 \
25-
python3-dev \
26-
python3-pip \
2724
numactl \
2825
gcc-12 \
2926
g++-12 \
30-
make \
31-
cmake
27+
make
3228
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
3329
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
3430
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 && \
35-
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 && \
36-
update-alternatives --install /usr/bin/python python /usr/bin/python3 100
31+
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
3732

3833
WORKDIR /root
39-
ENV PATH=/root/.local/bin:${PATH}
34+
35+
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 && \
36+
bash miniforge.sh -b -p ./miniforge3 && \
37+
rm miniforge.sh
4038

4139
# --build-arg COMPILE=ON to compile from source
4240
FROM base AS dev
4341
ARG COMPILE
4442
COPY . ./intel-extension-for-pytorch
45-
RUN cd intel-extension-for-pytorch/examples/cpu/llm && \
43+
RUN . ~/miniforge3/bin/activate && conda create -y -n compile_py310 python=3.10 && conda activate compile_py310 && \
44+
cd intel-extension-for-pytorch/examples/cpu/llm && \
4645
export CC=gcc && export CXX=g++ && \
4746
if [ -z ${COMPILE} ]; then bash tools/env_setup.sh 6; else bash tools/env_setup.sh 2; fi && \
4847
unset CC && unset CXX
@@ -58,8 +57,8 @@ RUN apt update && \
5857
if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi
5958
COPY --from=dev /root/intel-extension-for-pytorch/examples/cpu/llm ./llm
6059
COPY --from=dev /root/intel-extension-for-pytorch/tools/get_libstdcpp_lib.sh ./llm/tools
61-
RUN cd /usr/lib/x86_64-linux-gnu/ && ln -s libtcmalloc.so.4 libtcmalloc.so && cd && \
62-
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ./.bashrc && \
60+
RUN . ~/miniforge3/bin/activate && conda create -y -n py310 python=3.10 && conda activate py310 && \
61+
cd /usr/lib/x86_64-linux-gnu/ && ln -s libtcmalloc.so.4 libtcmalloc.so && cd && \
6362
cd ./llm && \
6463
bash tools/env_setup.sh 1 && \
6564
python -m pip cache purge && \
@@ -74,3 +73,15 @@ RUN mkdir /var/run/sshd && \
7473
mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
7574
echo "Host *\n Port ${PORT_SSH}\n IdentityFile /root/.ssh/id_rsa\n StrictHostKeyChecking no" > /root/.ssh/config
7675
EXPOSE ${PORT_SSH}
76+
RUN ENTRYPOINT=/usr/local/bin/entrypoint.sh && \
77+
echo "#!/bin/bash" > ${ENTRYPOINT} && \
78+
echo "CMDS=(); while [ \$# -gt 0 ]; do CMDS+=(\$1); shift; done;" >> ${ENTRYPOINT} && \
79+
echo "CMD=\"\"; for i in \${!CMDS[@]}; do CMD=\"\${CMD} \${CMDS[\$i]}\"; done;" >> ${ENTRYPOINT} && \
80+
echo ". ~/miniforge3/bin/activate" >> ${ENTRYPOINT} && \
81+
echo "conda activate py310" >> ${ENTRYPOINT} && \
82+
echo "TMP=\$(python -c \"import torch; import os; print(os.path.abspath(os.path.dirname(torch.__file__)))\")" >> ${ENTRYPOINT} && \
83+
echo ". \${TMP}/../oneccl_bindings_for_pytorch/env/setvars.sh" >> ${ENTRYPOINT} && \
84+
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ${ENTRYPOINT} && \
85+
echo "exec \${CMD}" >> ${ENTRYPOINT} && \
86+
chmod +x ${ENTRYPOINT}
87+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

examples/cpu/llm/tools/env_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ if [ $((${MODE} & 0x02)) -ne 0 ]; then
183183
rm -rf lm-evaluation-harness
184184

185185
# Install DeepSpeed
186-
if [ $((${MODE} & 0x08)) -ne 0 ]; then
186+
if [ $((${MODE} & 0x08)) -ge 0 ]; then
187187
if [ -d DeepSpeed ]; then
188188
rm -rf DeepSpeed
189189
fi

scripts/compile_bundle.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -eo pipefail
33

4-
VER_IPEX=main
4+
VER_IPEX=v2.5.0+cpu
55

66
# Mode: Select which components to install. PyTorch and Intel® Extension for PyTorch* are always installed.
77
# High bit: 8 7 6 5 4 3 2 1 :Low bit
@@ -23,7 +23,7 @@ if [ $# -gt 0 ]; then
2323
fi
2424

2525
# Check existance of required Linux commands
26-
for CMD in git nproc; do
26+
for CMD in git nproc make; do
2727
command -v ${CMD} > /dev/null || (echo "Error: Command \"${CMD}\" not found." ; exit 1)
2828
done
2929

@@ -75,7 +75,7 @@ if [ -z "${MAX_JOBS}" ]; then
7575
fi
7676

7777
# Install dependencies
78-
python -m pip install cmake==3.28.4 make
78+
python -m pip install cmake==3.28.4
7979

8080
# Compare the torch torchvision and torchaudio version
8181
function ver_compare_eq() {
@@ -207,6 +207,8 @@ else
207207
DIR_GCC=$(which gcc)
208208
if [ ! -z ${CONDA_PREFIX} ] && [[ ${DIR_GCC} =~ ${CONDA_PREFIX} ]]; then
209209
GCC_CONDA=2
210+
else
211+
GCC_CONDA=1
210212
fi
211213
fi
212214
fi
@@ -294,6 +296,7 @@ python -m pip install --force-reinstall dist/*.whl
294296
cd ..
295297
# Torch-CCL
296298
if [ $((${MODE} & 0x01)) -ne 0 ]; then
299+
conda install -y gcc==11.4 gxx==11.4 cxx-compiler -c conda-forge
297300
cd torch-ccl
298301
python setup.py clean
299302
python setup.py bdist_wheel 2>&1 | tee build.log

0 commit comments

Comments
 (0)