forked from thu-pacman/chitu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhygon.Dockerfile
More file actions
98 lines (88 loc) · 4.24 KB
/
hygon.Dockerfile
File metadata and controls
98 lines (88 loc) · 4.24 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
FROM image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04-py3.10-fixpy AS base
SHELL ["/bin/bash", "-c"]
ARG optional_deps=''
ARG chitu_setup_jobs=''
ARG enable_editable_install='false'
ARG enable_cython='true'
ARG enable_test='false'
ENV CHITU_SETUP_JOBS=$chitu_setup_jobs
ENV MAX_JOBS=$CHITU_SETUP_JOBS
RUN if [ "${enable_editable_install}" != "true" ] && [ "${enable_editable_install}" != "false" ]; then \
echo "ARG enable_editable_install must either be 'true' or 'false'"; \
exit 1; \
fi
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_cython}" = "true" ] && [ "${enable_editable_install}" = "true" ]; then \
echo "Cython is not supported when installing in editable mode"; \
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
ENV PIP_PROGRESS_BAR=off
ENV PIP_NO_CACHE_DIR=1
RUN pip install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple
# NOTE: Always apt update before apt install to avoid out-dated docker cache
# 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 \
apt update -y && apt install -y expect vim tmux telnet htop lsof strace iputils-ping && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytest aiohttp matplotlib; \
fi
RUN apt update -y && apt install -y curl
# 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
WORKDIR /workspace/chitu
COPY ./test ./test
COPY ./script ./script
COPY ./benchmarks ./benchmarks
ENV CHITU_HYGON_BUILD=1
# The actual installing procedure requries a NPU device, which is not available in the `docker build` stage.
# We delay it to an additional `docker run` stage which runs `script/install.sh`.