forked from thu-pacman/chitu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmuxi.Dockerfile
More file actions
117 lines (102 loc) · 5.29 KB
/
muxi.Dockerfile
File metadata and controls
117 lines (102 loc) · 5.29 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
FROM maca-pytorch:3.0.0.4-torch2.6-py310-ubuntu24.04-amd64 AS base
SHELL ["/bin/bash", "-c"]
ARG optional_deps=''
ARG chitu_setup_jobs=''
ARG enable_cython='true'
ARG enable_test='false'
ENV CHITU_SETUP_JOBS=$chitu_setup_jobs
ENV MAX_JOBS=$CHITU_SETUP_JOBS
# The base image uses Conda as the Python environment. We need to activate it
# For `docker build` stage, the most straightforward way is to use `bash --login -c` as the shell
SHELL ["/bin/bash", "--login", "-c"]
# For `docker run` stage, we need an entrypoint
RUN echo "source /etc/profile; \"\$@\"" > /entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
RUN if [ "${enable_cython}" != "true" ] && [ "${enable_cython}" != "false" ]; then \
echo "ARG enable_cython must either be 'true' or 'false'"; \
exit 1; \
fi
RUN if [ "${enable_test}" != "true" ] && [ "${enable_test}" != "false" ]; then \
echo "ARG enable_test must either be 'true' or 'false'"; \
exit 1; \
fi
# Required for non-interactive apt install
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN printf '%s\n' \
"deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" \
"deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" \
"deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" \
"deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse" \
> /etc/apt/sources.list; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates; \
update-ca-certificates; \
sed -i 's|http://mirrors.tuna.tsinghua.edu.cn|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
# NOTE: Always apt update before apt install to avoid out-dated docker cache
# NOTE: g++-11 a downgrading of g++, which is required by compiling muxi_layout_kernels. This is
# because mxcc can't compile C++20 when g++ is too new.
RUN apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends g++-11 curl; \
rm -rf /var/lib/apt/lists/*
# Download prometheus
RUN --mount=type=secret,id=tos_id \
--mount=type=secret,id=tos_key \
mkdir -p /workspace/prometheus && \
case "$(uname -m)" in \
x86_64|amd64) \
GITHUB_URL="https://github.com/prometheus/prometheus/releases/download/v3.9.1/prometheus-3.9.1.linux-amd64.tar.gz" && \
TOS_URL="tos://out-deliver/prometheus-3.9.1.linux-amd64.tar" && \
TOOL_URL="https://tos-tools.tos-cn-beijing.volces.com/linux/tosutil" \
;; \
aarch64|arm64) \
GITHUB_URL="https://github.com/prometheus/prometheus/releases/download/v3.9.1/prometheus-3.9.1.linux-arm64.tar.gz" && \
TOS_URL="tos://out-deliver/prometheus-3.9.1.linux-arm64.tar" && \
TOOL_URL="https://m645b3e1bb36e-mrap.mrap.accesspoint.tos-global.volces.com/linux/arm64/tosutil" \
;; \
*) \
echo "Unsupport arch: $(uname -m)" && exit 1 \
;; \
esac && \
if [ -s /run/secrets/tos_id ] && [ -s /run/secrets/tos_key ]; then \
echo "tos_id and tos_id exits, download prometheus from Tos" && \
tos_id=$(cat /run/secrets/tos_id) && \
tos_key=$(cat /run/secrets/tos_key) && \
mkdir -p /workspace/prometheus && \
mkdir -p /tmp && curl "${TOOL_URL}" --output /tmp/tosutil && chmod a+x /tmp/tosutil && \
/tmp/tosutil cp -u -r -p=8 -j=8 -threshold=104857600 -k "${tos_key}" -i "${tos_id}" \
-e tos-cn-beijing.volces.com -re out-deliver.tos-cn-beijing.volces.com "${TOS_URL}" /workspace && \
tar -xf /workspace/prometheus-*.tar --strip-components=1 -C /workspace/prometheus && \
rm -rf /workspace/prometheus-*.tar && \
rm -rf /tmp/tosutil; \
else \
echo "Download prometheus from GitHub" && \
curl -L --retry 3 --retry-delay 5 -o /workspace/prometheus.tar.gz "${GITHUB_URL}" && \
tar -xzvf /workspace/prometheus.tar.gz --strip-components=1 -C /workspace/prometheus && \
rm -rf /workspace/prometheus.tar.gz; \
fi && \
cp /workspace/prometheus/prometheus /usr/local/bin && \
cp /workspace/prometheus/promtool /usr/local/bin/ && \
rm -rf /workspace/prometheus && \
prometheus --version
RUN if [ "${enable_test}" = "true" ]; then \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends expect vim tmux telnet htop lsof strace iputils-ping; \
rm -rf /var/lib/apt/lists/*; \
fi
# NOTE: Test dependencies include:
# - pytest is for test/pytest (for all platforms).
# - aiohttp is for service tests (for all platforms).
# - matplotlib is for benchmarks/op_bench (for platforms with triton).
RUN if [ "${enable_test}" = "true" ]; then \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytest aiohttp matplotlib; \
fi
WORKDIR /workspace/chitu
COPY ./test ./test
COPY ./script ./script
COPY ./benchmarks ./benchmarks
ENV CHITU_MUXI_BUILD=1
# The actual installing procedure requries a GPU device, which is not available in the `docker build` stage.
# We delay it to an additional `docker run` stage which runs `script/install.sh`.