|
|
|
@@ -19,22 +19,15 @@ ARG GFX=gfx120X-all
|
|
|
|
|
RUN set -euo pipefail; \
|
|
|
|
|
BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \
|
|
|
|
|
PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \
|
|
|
|
|
echo "Fetching file list from ${BASE}..."; \
|
|
|
|
|
KEY="$(curl -x socks5://192.168.0.11:1080 -s "${BASE}?list-type=2&prefix=${PREFIX}" \
|
|
|
|
|
KEY="$(proxychains curl -s "${BASE}?list-type=2&prefix=${PREFIX}" \
|
|
|
|
|
| tr '<' '\n' \
|
|
|
|
|
| grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \
|
|
|
|
|
| sort -V | tail -n1)"; \
|
|
|
|
|
if [ -z "$KEY" ]; then \
|
|
|
|
|
echo "ERROR: Failed to get tarball filename"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi; \
|
|
|
|
|
echo "Downloading Latest Tarball: ${KEY}"; \
|
|
|
|
|
curl -x socks5://192.168.0.11:1080 -L -o therock.tar.gz "${BASE}/${KEY}" || { echo "ERROR: Download failed"; exit 1; }; \
|
|
|
|
|
echo "Extracting tarball..."; \
|
|
|
|
|
proxychains aria2c -x 16 -s 16 -j 16 --file-allocation=none "${BASE}/${KEY}" -o therock.tar.gz; \
|
|
|
|
|
mkdir -p /opt/rocm; \
|
|
|
|
|
tar xzf therock.tar.gz -C /opt/rocm --strip-components=1 || { echo "ERROR: Extraction failed"; exit 1; }; \
|
|
|
|
|
rm therock.tar.gz; \
|
|
|
|
|
echo "ROCm SDK installed successfully"
|
|
|
|
|
tar xzf therock.tar.gz -C /opt/rocm --strip-components=1; \
|
|
|
|
|
rm therock.tar.gz
|
|
|
|
|
|
|
|
|
|
# 3. Configure Global ROCm Environment
|
|
|
|
|
RUN export ROCM_PATH=/opt/rocm && \
|
|
|
|
@@ -74,9 +67,9 @@ RUN proxychains python -m pip install \
|
|
|
|
|
WORKDIR /opt
|
|
|
|
|
ENV FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE"
|
|
|
|
|
|
|
|
|
|
RUN proxychains git clone https://github.com/ROCm/flash-attention.git &&\
|
|
|
|
|
cd flash-attention &&\
|
|
|
|
|
git checkout main_perf &&\
|
|
|
|
|
RUN proxychains git clone https://github.com/ROCm/flash-attention.git && \
|
|
|
|
|
cd flash-attention && \
|
|
|
|
|
git checkout main_perf && \
|
|
|
|
|
python setup.py install && \
|
|
|
|
|
cd /opt && rm -rf /opt/flash-attention
|
|
|
|
|
|
|
|
|
@@ -85,11 +78,8 @@ RUN proxychains git clone https://github.com/vllm-project/vllm.git /opt/vllm
|
|
|
|
|
WORKDIR /opt/vllm
|
|
|
|
|
|
|
|
|
|
# --- PATCHING ---
|
|
|
|
|
# vLLM relies on 'amdsmi' to detect AMD GPUs. If it's missing or fails (common in containers),
|
|
|
|
|
# vLLM falls back to CPU. We patch it to force ROCm detection.
|
|
|
|
|
RUN echo "import sys, re" > patch_vllm.py && \
|
|
|
|
|
echo "from pathlib import Path" >> patch_vllm.py && \
|
|
|
|
|
# Patch 1: __init__.py - Force is_rocm=True and bypass amdsmi checks
|
|
|
|
|
echo "p = Path('vllm/platforms/__init__.py')" >> patch_vllm.py && \
|
|
|
|
|
echo "txt = p.read_text()" >> patch_vllm.py && \
|
|
|
|
|
echo "txt = txt.replace('import amdsmi', '# import amdsmi')" >> patch_vllm.py && \
|
|
|
|
@@ -98,7 +88,6 @@ RUN echo "import sys, re" > patch_vllm.py && \
|
|
|
|
|
echo "txt = txt.replace('amdsmi.amdsmi_init()', 'pass')" >> patch_vllm.py && \
|
|
|
|
|
echo "txt = txt.replace('amdsmi.amdsmi_shut_down()', 'pass')" >> patch_vllm.py && \
|
|
|
|
|
echo "p.write_text(txt)" >> patch_vllm.py && \
|
|
|
|
|
# Patch 2: rocm.py - Mock amdsmi and force device name
|
|
|
|
|
echo "p = Path('vllm/platforms/rocm.py')" >> patch_vllm.py && \
|
|
|
|
|
echo "txt = p.read_text()" >> patch_vllm.py && \
|
|
|
|
|
echo "header = 'import sys\nfrom unittest.mock import MagicMock\nsys.modules[\"amdsmi\"] = MagicMock()\n'" >> patch_vllm.py && \
|
|
|
|
@@ -110,19 +99,16 @@ RUN echo "import sys, re" > patch_vllm.py && \
|
|
|
|
|
echo "print('Successfully patched vLLM for R9700')" >> patch_vllm.py && \
|
|
|
|
|
python patch_vllm.py
|
|
|
|
|
|
|
|
|
|
# 7. Build vLLM (Wheel Method) with CLANG Host Compiler
|
|
|
|
|
# 7. Build vLLM
|
|
|
|
|
RUN python -m pip install --upgrade cmake ninja packaging wheel numpy "setuptools-scm>=8" "setuptools<80.0.0" scikit-build-core pybind11
|
|
|
|
|
ENV ROCM_HOME="/opt/rocm"
|
|
|
|
|
ENV HIP_PATH="/opt/rocm"
|
|
|
|
|
ENV VLLM_TARGET_DEVICE="rocm"
|
|
|
|
|
ENV PYTORCH_ROCM_ARCH="gfx1201"
|
|
|
|
|
ENV HIP_ARCHITECTURES="gfx1201"
|
|
|
|
|
ENV AMDGPU_TARGETS="gfx1201"
|
|
|
|
|
ENV HIP_ARCHITECTURES="gfx1201"
|
|
|
|
|
ENV AMDGPU_TARGETS="gfx1201"
|
|
|
|
|
ENV MAX_JOBS="32"
|
|
|
|
|
|
|
|
|
|
# --- FIX FOR SEGFAULT ---
|
|
|
|
|
# We force the Host Compiler (CC/CXX) to be the ROCm Clang, not Fedora GCC.
|
|
|
|
|
# This aligns the ABI of the compiled vLLM extensions with PyTorch.
|
|
|
|
|
ENV CC="/opt/rocm/llvm/bin/clang"
|
|
|
|
|
ENV CXX="/opt/rocm/llvm/bin/clang++"
|
|
|
|
|
|
|
|
|
@@ -133,16 +119,14 @@ RUN export HIP_DEVICE_LIB_PATH=$(find /opt/rocm -type d -name bitcode -print -qu
|
|
|
|
|
python -m pip wheel --no-build-isolation --no-deps -w /tmp/dist -v . && \
|
|
|
|
|
python -m pip install /tmp/dist/*.whl
|
|
|
|
|
|
|
|
|
|
# --- bitsandbytes (ROCm) ---
|
|
|
|
|
# bitsandbytes
|
|
|
|
|
WORKDIR /opt
|
|
|
|
|
RUN proxychains git clone -b rocm_enabled_multi_backend https://github.com/ROCm/bitsandbytes.git
|
|
|
|
|
WORKDIR /opt/bitsandbytes
|
|
|
|
|
|
|
|
|
|
# Explicitly set HIP_PLATFORM (Docker ENV, not /etc/profile)
|
|
|
|
|
ENV HIP_PLATFORM="amd"
|
|
|
|
|
ENV CMAKE_PREFIX_PATH="/opt/rocm"
|
|
|
|
|
|
|
|
|
|
# Force CMake to use the System ROCm Compiler (/opt/rocm/llvm/bin/clang++)
|
|
|
|
|
RUN cmake -S . \
|
|
|
|
|
-DGPU_TARGETS="gfx1201" \
|
|
|
|
|
-DBNB_ROCM_ARCH="gfx1201" \
|
|
|
|
@@ -153,7 +137,7 @@ RUN cmake -S . \
|
|
|
|
|
make -j$(nproc) && \
|
|
|
|
|
python -m pip install --no-cache-dir . --no-build-isolation --no-deps
|
|
|
|
|
|
|
|
|
|
# 8. Final Cleanup & Runtime
|
|
|
|
|
# Cleanup
|
|
|
|
|
WORKDIR /opt
|
|
|
|
|
RUN chmod -R a+rwX /opt && \
|
|
|
|
|
find /opt/venv -type f -name "*.so" -exec strip -s {} + 2>/dev/null || true && \
|
|
|
|
@@ -161,11 +145,8 @@ RUN chmod -R a+rwX /opt && \
|
|
|
|
|
rm -rf /root/.cache/pip || true && \
|
|
|
|
|
dnf clean all && rm -rf /var/cache/dnf/*
|
|
|
|
|
|
|
|
|
|
# Create vLLM configuration directory and model directory
|
|
|
|
|
RUN mkdir -p /etc/vllm && \
|
|
|
|
|
mkdir -p /model
|
|
|
|
|
RUN mkdir -p /etc/vllm && mkdir -p /model
|
|
|
|
|
|
|
|
|
|
# Copy necessary scripts
|
|
|
|
|
COPY scripts/01-rocm-envs.sh /etc/profile.d/01-rocm-envs.sh
|
|
|
|
|
COPY scripts/99-toolbox-banner.sh /etc/profile.d/99-toolbox-banner.sh
|
|
|
|
|
COPY scripts/zz-venv-last.sh /etc/profile.d/zz-venv-last.sh
|
|
|
|
|