-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile.triton-amd
110 lines (99 loc) · 3.92 KB
/
Dockerfile.triton-amd
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
# 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
ARG ROCM_VERSION=6.2
# LLVM Build Stage
FROM registry.access.redhat.com/ubi9/ubi:latest AS llvm-build
ARG CUSTOM_LLVM
USER 0
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/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 && \
dnf clean all && rm -rf /var/cache/dnf /tmp/*; \
else \
echo "Skipping LLVM build because CUSTOM_LLVM is not true"; \
mkdir llvm-project; \
fi
# Base Stage with ROCm Installation
FROM registry.access.redhat.com/ubi9/python-311 AS base
ARG ROCM_VERSION=6.2
USER 0
# Install the ROCm rpms
RUN echo "[ROCm]" > /etc/yum.repos.d/rocm.repo && \
echo "name=ROCm" >> /etc/yum.repos.d/rocm.repo && \
echo "baseurl=https://repo.radeon.com/rocm/rhel9/$ROCM_VERSION/main" >> /etc/yum.repos.d/rocm.repo && \
echo "enabled=1" >> /etc/yum.repos.d/rocm.repo && \
echo "gpgcheck=0" >> /etc/yum.repos.d/rocm.repo && \
dnf install -y llvm clang clang-libs lld && \
dnf install -y --nodocs --setopt=install_weak_deps=False \
amd-smi-lib \
amd-smi \
miopen-hip \
rocm-core \
rocm-hip-libraries \
rocminfo && \
dnf clean all && rm -rf /var/cache/yum
# Set environment variables for ROCm
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
ROCM_PATH=/opt/rocm \
LD_LIBRARY_PATH=/usr/lib64:/usr/lib:/opt/rocm/lib:/opt/rocm/llvm/lib \
PATH=/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH
# LLVM Integration Stages
FROM base AS llvm-local-true
COPY --from=llvm-build /llvm-project/ /llvm-project/
FROM base AS llvm-local-false
ENV TRITON_OFFLINE_BUILD=NO
# Final Stage
FROM llvm-local-${CUSTOM_LLVM} AS final
ARG ROCM_VERSION=6.2
# Create the /workspace directory and set permissions
RUN mkdir -p /workspace && \
python -m venv /workspace && \
echo "unset BASH_ENV PROMPT_COMMAND ENV" >> /workspace/bin/activate && \
chmod -R 777 /workspace
ENV BASH_ENV=/workspace/bin/activate \
ENV=/workspace/bin/activate \
PROMPT_COMMAND=". /workspace/bin/activate" \
PYTHON_VERSION=3.11 \
PATH=/workspace/bin:$PATH \
PYTHONUNBUFFERED=1 \
AMD=true \
ROCM_VERSION=$ROCM_VERSION \
PIP_PREFIX=/workspace \
PYTHONPATH=/workspace/lib/python$PYTHON_VERSION/site-packages \
XDG_CACHE_HOME=/workspace \
TRITON_CACHE_DIR=/workspace/.triton/cache \
TRITON_HOME=/workspace/
WORKDIR /workspace
RUN echo 'export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
RUN echo "export MAX_JOBS=$(nproc --all)" >> "${HOME}"/.bashrc
COPY --from=quay.io/triton-dev-containers/gosu /usr/local/bin/gosu /usr/local/bin/gosu
COPY user.sh user.sh
COPY entrypoint.sh /entrypoint.sh
COPY hack/triton-gpu-check.py triton-gpu-check.py
COPY examples/triton-vector-add-rocm.py triton-vector-add-rocm.py
COPY examples/flash_attention_demo.ipynb flash_attention_demo.ipynb
ENTRYPOINT ["/entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]