Repository navigation
Expand file tree
/
Copy pathDockerfile.rocm
More file actions
81 lines (68 loc) · 2.82 KB
/
Copy pathDockerfile.rocm
File metadata and controls
81 lines (68 loc) · 2.82 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
# syntax=docker/dockerfile:1
# ROCm/HIP image for AMD GPUs. Defaults to gfx942 (MI300, ROCm 6.4); set
# ROCM_GFX_ARCH=gfx90a for MI200. For gfx1151 (Strix Halo) pass a ROCm 7.x base
# (ROCM_BASE=rocm/dev-ubuntu-24.04:7.2.4) plus ROCM_GFX_ARCH=gfx1151.
ARG ROCM_BASE=rocm/dev-ubuntu-24.04:6.4.4
# Stage 1: Build environment
FROM ${ROCM_BASE} AS builder
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
RUN <<HEREDOC
for i in 1 2 3 4 5; do apt-get -o Acquire::Retries=3 update && break; echo "apt-get update failed (attempt $i/5), mirror may be syncing; retrying in 15s"; sleep 15; done
apt-get install -y --no-install-recommends \
curl \
git \
libclang-dev \
libssl-dev \
miopen-hip-dev \
pkg-config \
rocblas-dev \
rocfft-dev \
rocrand-dev \
rocsolver-dev \
rocsparse-dev
rm -rf /var/lib/apt/lists/*
HEREDOC
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV ROCM_PATH=/opt/rocm
ENV PATH="/root/.cargo/bin:/opt/rocm/bin:${PATH}"
RUN rustup update nightly && rustup default nightly
WORKDIR /hanzo
COPY . .
# ROCM_GFX_ARCH is read by build.rs to compile the HIP kernels for the target ISA.
ARG ROCM_GFX_ARCH=gfx942
ENV ROCM_GFX_ARCH=${ROCM_GFX_ARCH}
ARG WITH_FEATURES="rocm"
# Portable, memory-bounded release build. These MUST be ENV, not ARG, or cargo
# never sees them:
# RUSTFLAGS="" overrides .cargo/config.toml `target-cpu=native` (SIGILL on
# other hosts otherwise).
# CARGO_BUILD_JOBS=2 caps concurrent rustc so the ARC pod does not OOM (the
# unbounded default recycled the runner mid-compile).
ENV RUSTFLAGS="" \
CARGO_INCREMENTAL=0 \
CARGO_NET_RETRY=5 \
CARGO_BUILD_JOBS=2 \
RAYON_NUM_THREADS=4
# Only the two binaries the runtime stage copies (hanzo-server, hanzo-bench).
RUN cargo build --release -p hanzo-server -p hanzo-bench --features "${WITH_FEATURES}"
# Stage 2: Minimal runtime environment
FROM ${ROCM_BASE} AS runtime
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
RUN <<HEREDOC
for i in 1 2 3 4 5; do apt-get -o Acquire::Retries=3 update && break; echo "apt-get update failed (attempt $i/5), mirror may be syncing; retrying in 15s"; sleep 15; done
apt-get install -y --no-install-recommends \
libomp-dev \
ca-certificates \
libssl-dev \
curl \
pkg-config
rm -rf /var/lib/apt/lists/*
HEREDOC
COPY --chmod=755 --from=builder /hanzo/target/release/hanzo-bench /usr/local/bin/hanzo-bench
COPY --chmod=755 --from=builder /hanzo/target/release/hanzo-server /usr/local/bin/hanzo-server
# Copy chat templates for users running models which may not include them
COPY --from=builder /hanzo/chat_templates /chat_templates
ENV HUGGINGFACE_HUB_CACHE=/data \
PORT=80