Skip to content

Commit 7b3a04d

Browse files
authored
Merge pull request #923 from dmedovich/feat/vllm-rocm-use-wheels
refactor: install vLLM ROCm from upstream wheels
2 parents 91c1fe1 + 2dbc908 commit 7b3a04d

2 files changed

Lines changed: 28 additions & 55 deletions

File tree

Dockerfile

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -153,64 +153,38 @@ FROM sglang AS final-sglang
153153
# Copy the built binary from builder-sglang (without vLLM)
154154
COPY --from=builder-sglang /app/model-runner /app/model-runner
155155

156-
# --- vLLM ROCm: builder stage ---
157-
# Builds upstream vLLM from source on AMD's pre-built ROCm dev image, which
158-
# already contains PyTorch ROCm, Triton, flash-attention, and the ROCm SDK
159-
# (see https://hub.docker.com/r/rocm/vllm-dev). vLLM is checked out at the
160-
# tagged release matching VLLM_VERSION — no fork, no custom wheels.
161-
FROM rocm/vllm-dev:base AS vllm-rocm-builder
162-
163-
ARG VLLM_VERSION=0.19.1
164-
# Target GPU architectures officially supported by vLLM ROCm:
165-
# gfx90a (MI200), gfx942 (MI300), gfx1100/1101 (RDNA3 7900/7800).
166-
ARG PYTORCH_ROCM_ARCH="gfx90a;gfx942;gfx1100;gfx1101"
167-
ENV PYTORCH_ROCM_ARCH=${PYTORCH_ROCM_ARCH}
168-
169-
RUN git clone --depth 1 --branch v${VLLM_VERSION} \
170-
https://github.com/vllm-project/vllm.git /vllm-src
171-
172-
WORKDIR /vllm-src
173-
RUN python3 -m pip install --no-cache-dir -r requirements/rocm.txt \
174-
&& python3 setup.py bdist_wheel --dist-dir=/wheels
175-
176-
# --- vLLM ROCm: runtime stage ---
177-
# Mirrors the /opt/vllm-env layout that pkg/inference/backends/vllm/vllm.go
178-
# expects (binary at /opt/vllm-env/bin/vllm, version file at
179-
# /opt/vllm-env/version). Symlinks are used instead of a real venv because
180-
# rocm/vllm-dev:base installs Python dependencies system-wide and recreating
181-
# a venv would break the PyTorch ROCm / Triton ROCm wiring.
156+
# --- vLLM ROCm variant ---
157+
# Installs upstream vLLM ROCm wheels published by the vLLM project at
158+
# https://wheels.vllm.ai/rocm/. These wheels bundle PyTorch ROCm, Triton ROCm,
159+
# flash-attention ROCm, and AITER, so we can stay on the llama.cpp ROCm base
160+
# (keeping llama.cpp available as a fallback inside the image, like the CUDA
161+
# variant does).
182162
#
183-
# Note: unlike the CUDA vllm stage, this image does NOT include llama.cpp.
184-
# The base image is incompatible (different ROCm runtime versions), and the
185-
# rocm vllm image is intended as a vLLM-only artifact.
186-
FROM rocm/vllm-dev:base AS vllm-rocm
163+
# Note: vLLM ROCm wheels follow a separate release cadence from CUDA — only
164+
# specific vLLM versions are published with ROCm support, so VLLM_ROCM_VERSION
165+
# is tracked independently from VLLM_VERSION (CUDA).
166+
FROM llamacpp AS vllm-rocm
187167

188-
COPY --from=vllm-rocm-builder /wheels/*.whl /tmp/
189-
RUN python3 -m pip install --no-cache-dir /tmp/*.whl && rm /tmp/*.whl
168+
ARG VLLM_ROCM_VERSION=0.21.0
169+
ARG VLLM_ROCM_TARGET=rocm722
190170

191-
RUN groupadd --system modelrunner \
192-
&& useradd --system --gid modelrunner -G video \
193-
--create-home --home-dir /home/modelrunner modelrunner
171+
USER root
194172

195-
RUN mkdir -p /opt/vllm-env/bin \
196-
&& ln -s "$(command -v vllm)" /opt/vllm-env/bin/vllm \
197-
&& python3 -c "import vllm; print(vllm.__version__)" > /opt/vllm-env/version \
198-
&& chown -R modelrunner:modelrunner /opt/vllm-env
173+
RUN apt update && apt install -y python3.12 python3.12-venv python3.12-dev curl ca-certificates build-essential && rm -rf /var/lib/apt/lists/*
199174

200-
RUN mkdir -p /var/run/model-runner /models /app \
201-
&& chown -R modelrunner:modelrunner /var/run/model-runner /app /models \
202-
&& chmod -R 755 /models
175+
RUN mkdir -p /opt/vllm-env && chown -R modelrunner:modelrunner /opt/vllm-env
203176

204177
USER modelrunner
205178

206-
ENV MODEL_RUNNER_SOCK=/var/run/model-runner/model-runner.sock
207-
ENV MODEL_RUNNER_PORT=12434
208-
ENV HOME=/home/modelrunner
209-
ENV MODELS_PATH=/models
210-
211-
LABEL com.docker.desktop.service="model-runner"
179+
# Install uv and vLLM with ROCm wheels as modelrunner user
180+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
181+
&& ~/.local/bin/uv venv --python 3.12 /opt/vllm-env \
182+
&& . /opt/vllm-env/bin/activate \
183+
&& ~/.local/bin/uv pip install "vllm==${VLLM_ROCM_VERSION}" \
184+
--extra-index-url https://wheels.vllm.ai/rocm/${VLLM_ROCM_VERSION}/${VLLM_ROCM_TARGET} \
185+
--index-strategy unsafe-best-match
212186

213-
ENTRYPOINT ["/app/model-runner"]
187+
RUN /opt/vllm-env/bin/python3.12 -c "import vllm; print(vllm.__version__)" > /opt/vllm-env/version
214188

215189
FROM vllm-rocm AS final-vllm-rocm
216190
# Copy the built binary from builder

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,10 @@ docker-run-vllm: docker-build-vllm
196196
@$(MAKE) -s docker-run-impl DOCKER_IMAGE=$(DOCKER_IMAGE_VLLM)
197197

198198
# Build vLLM Docker image with ROCm (AMD GPU) support.
199-
# Builds upstream vLLM from source on top of rocm/vllm-dev:base — this is a
200-
# vLLM-only image (no llama.cpp), unlike the CUDA variant. Build is heavy:
201-
# expect 30-60 min and ~12-15 GB final image size.
202-
# LLAMA_SERVER_VARIANT is not consumed by the Dockerfile stages here, but
203-
# setting it to "rocm" restricts DOCKER_BUILD_PLATFORMS to linux/amd64
199+
# Installs upstream vLLM ROCm wheels from https://wheels.vllm.ai/rocm/ on
200+
# top of the llama.cpp ROCm base, so the image keeps llama.cpp available
201+
# (mirrors the CUDA vllm variant shape).
202+
# LLAMA_SERVER_VARIANT=rocm restricts DOCKER_BUILD_PLATFORMS to linux/amd64
204203
# (vLLM ROCm has no aarch64 support).
205204
docker-build-vllm-rocm:
206205
@$(MAKE) docker-build \
@@ -422,7 +421,7 @@ help:
422421
@echo " docker-run - Run in Docker container with TCP port access and mounted model storage"
423422
@echo " docker-build-vllm - Build vLLM Docker image (CUDA)"
424423
@echo " docker-run-vllm - Run vLLM Docker container (CUDA)"
425-
@echo " docker-build-vllm-rocm - Build vLLM Docker image (ROCm / AMD GPU, source build)"
424+
@echo " docker-build-vllm-rocm - Build vLLM Docker image (ROCm / AMD GPU)"
426425
@echo " docker-run-vllm-rocm - Run vLLM Docker container (ROCm / AMD GPU)"
427426
@echo " docker-build-sglang - Build SGLang Docker image"
428427
@echo " docker-run-sglang - Run SGLang Docker container"

0 commit comments

Comments
 (0)