-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.triton-cpu
95 lines (83 loc) · 3.24 KB
/
Dockerfile.triton-cpu
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
# Copyright (C) 2024-2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
ARG CUSTOM_LLVM=false
FROM registry.access.redhat.com/ubi9/ubi:latest AS llvm-build
ARG CUSTOM_LLVM
USER 0
# Conditionally execute the build based on CUSTOM_LLVM
RUN if [ "$CUSTOM_LLVM" = "true" ]; then \
dnf update -y && \
dnf -y install clang rpm-build git ninja-build cmake lld && \
git clone https://github.com/llvm/llvm-project && \
cd llvm-project && \
COMMIT=$(curl -s https://raw.githubusercontent.com/triton-lang/triton-cpu/refs/heads/main/cmake/llvm-hash.txt) &&\
git checkout $COMMIT && \
mkdir build && \
cd build && \
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON ../llvm -DLLVM_ENABLE_PROJECTS="mlir;llvm" -DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" && \
ninja; \
else \
echo "Skipping LLVM build because CUSTOM_LLVM is not true"; \
fi
FROM registry.access.redhat.com/ubi9/ubi:latest AS gosu
ENV GOSU_VERSION=1.17
RUN dnf update -y && \
dnf -y install wget && \
dnf clean all
RUN set -eux; \
rpmArch="$(rpm --query --queryformat='%{ARCH}' rpm)"; \
case "$rpmArch" in \
aarch64) dpkgArch='arm64' ;; \
armv[67]*) dpkgArch='armhf' ;; \
i[3456]86) dpkgArch='i386' ;; \
ppc64le) dpkgArch='ppc64el' ;; \
riscv64 | s390x) dpkgArch="$rpmArch" ;; \
x86_64) dpkgArch='amd64' ;; \
*) echo >&2 "error: unknown/unsupported architecture '$rpmArch'"; exit 1 ;; \
esac; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
chmod +x /usr/local/bin/gosu;
FROM registry.access.redhat.com/ubi9/python-312 AS base
ARG CUSTOM_LLVM
USER 0
RUN dnf update -y && \
dnf -y install clang cmake lld ninja-build \
openblas openblas-devel llvm llvm-libs libomp libomp-devel && \
dnf clean all
# Stage for llvm-local-true
FROM base AS llvm-local-true
COPY --from=llvm-build /llvm-project/ /llvm-project/
# Stage for llvm-local-false
FROM base AS llvm-local-false
ENV TRITON_OFFLINE_BUILD=NO
# Use intermediate stage selection
FROM llvm-local-${CUSTOM_LLVM} AS final
ARG USERNAME=1001
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV PYTHON_VERSION=3.12 \
PATH=$HOME/.local/bin/:$PATH \
PYTHONUNBUFFERED=1 \
TRITON_CPU_BACKEND=1
WORKDIR /opt
RUN echo 'export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
RUN echo "export MAX_JOBS=$(nproc --all)" >> "${HOME}"/.bashrc
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
COPY user.sh user.sh
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]