-
Notifications
You must be signed in to change notification settings - Fork 271
/
Copy pathDockerfile.prebuilt
74 lines (66 loc) · 3.23 KB
/
Dockerfile.prebuilt
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
# Copyright (c) 2024 Intel Corporation
# SPDX-License-Identifier: Apache 2.0
# 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 UBUNTU_VERSION=22.04
FROM ubuntu:${UBUNTU_VERSION}
# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8
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 -y && \
apt full-upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt install -y \
python3 \
python3-pip \
python3-dev \
python3-venv \
google-perftools \
openssh-server \
net-tools
RUN 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
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 100
WORKDIR /root
ARG IPEX_VERSION=2.7.0
ARG TORCHCCL_VERSION=2.7.0
ARG PYTORCH_VERSION=2.7.0
ARG TORCHAUDIO_VERSION=2.7.0
ARG TORCHVISION_VERSION=0.22.0
RUN python -m venv venv && \
. ./venv/bin/activate && \
python -m pip --no-cache-dir install --upgrade \
pip \
setuptools \
psutil && \
python -m pip install --no-cache-dir \
torch==${PYTORCH_VERSION}+cpu torchvision==${TORCHVISION_VERSION}+cpu torchaudio==${TORCHAUDIO_VERSION}+cpu --index-url https://download.pytorch.org/whl/cpu && \
python -m pip install --no-cache-dir \
intel_extension_for_pytorch==${IPEX_VERSION} oneccl_bind_pt==${TORCHCCL_VERSION} --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/ && \
python -m pip install intel-openmp && \
python -m pip cache purge
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}
RUN ENTRYPOINT=/usr/local/bin/entrypoint.sh && \
echo "#!/bin/bash" > ${ENTRYPOINT} && \
echo "CMDS=(); while [ \$# -gt 0 ]; do CMDS+=(\$1); shift; done;" >> ${ENTRYPOINT} && \
echo "CMD=\"\"; for i in \${!CMDS[@]}; do CMD=\"\${CMD} \${CMDS[\$i]}\"; done;" >> ${ENTRYPOINT} && \
echo ". ~/venv/bin/activate" >> ${ENTRYPOINT} && \
echo "TMP=\$(python -c \"import torch; import os; print(os.path.abspath(os.path.dirname(torch.__file__)))\")" >> ${ENTRYPOINT} && \
echo ". \${TMP}/../oneccl_bindings_for_pytorch/env/setvars.sh" >> ${ENTRYPOINT} && \
echo "echo \"**Note:** For better performance, please consider to launch workloads with command 'ipexrun'.\"" >> ${ENTRYPOINT} && \
echo "exec \${CMD}" >> ${ENTRYPOINT} && \
chmod +x ${ENTRYPOINT}
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]