This commit is contained in:
2026-03-14 01:49:03 +08:00
parent 4e11b7f06b
commit 10abd1b7f6
6 changed files with 14 additions and 68 deletions
+11 -30
View File
@@ -19,22 +19,15 @@ ARG GFX=gfx120X-all
RUN set -euo pipefail; \ RUN set -euo pipefail; \
BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \ BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \
PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \ PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \
echo "Fetching file list from ${BASE}..."; \ KEY="$(proxychains curl -s "${BASE}?list-type=2&prefix=${PREFIX}" \
KEY="$(curl -x socks5://192.168.0.11:1080 -s "${BASE}?list-type=2&prefix=${PREFIX}" \
| tr '<' '\n' \ | tr '<' '\n' \
| grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \ | grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \
| sort -V | tail -n1)"; \ | sort -V | tail -n1)"; \
if [ -z "$KEY" ]; then \
echo "ERROR: Failed to get tarball filename"; \
exit 1; \
fi; \
echo "Downloading Latest Tarball: ${KEY}"; \ 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; }; \ proxychains aria2c -x 16 -s 16 -j 16 --file-allocation=none "${BASE}/${KEY}" -o therock.tar.gz; \
echo "Extracting tarball..."; \
mkdir -p /opt/rocm; \ mkdir -p /opt/rocm; \
tar xzf therock.tar.gz -C /opt/rocm --strip-components=1 || { echo "ERROR: Extraction failed"; exit 1; }; \ tar xzf therock.tar.gz -C /opt/rocm --strip-components=1; \
rm therock.tar.gz; \ rm therock.tar.gz
echo "ROCm SDK installed successfully"
# 3. Configure Global ROCm Environment # 3. Configure Global ROCm Environment
RUN export ROCM_PATH=/opt/rocm && \ RUN export ROCM_PATH=/opt/rocm && \
@@ -74,9 +67,9 @@ RUN proxychains python -m pip install \
WORKDIR /opt WORKDIR /opt
ENV FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE" ENV FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE"
RUN proxychains git clone https://github.com/ROCm/flash-attention.git &&\ RUN proxychains git clone https://github.com/ROCm/flash-attention.git && \
cd flash-attention &&\ cd flash-attention && \
git checkout main_perf &&\ git checkout main_perf && \
python setup.py install && \ python setup.py install && \
cd /opt && rm -rf /opt/flash-attention 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 WORKDIR /opt/vllm
# --- PATCHING --- # --- 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 && \ RUN echo "import sys, re" > patch_vllm.py && \
echo "from pathlib import Path" >> 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 "p = Path('vllm/platforms/__init__.py')" >> patch_vllm.py && \
echo "txt = p.read_text()" >> patch_vllm.py && \ echo "txt = p.read_text()" >> patch_vllm.py && \
echo "txt = txt.replace('import amdsmi', '# import amdsmi')" >> 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_init()', 'pass')" >> patch_vllm.py && \
echo "txt = txt.replace('amdsmi.amdsmi_shut_down()', 'pass')" >> patch_vllm.py && \ echo "txt = txt.replace('amdsmi.amdsmi_shut_down()', 'pass')" >> patch_vllm.py && \
echo "p.write_text(txt)" >> 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 "p = Path('vllm/platforms/rocm.py')" >> patch_vllm.py && \
echo "txt = p.read_text()" >> 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 && \ echo "header = 'import sys\nfrom unittest.mock import MagicMock\nsys.modules[\"amdsmi\"] = MagicMock()\n'" >> patch_vllm.py && \
@@ -110,7 +99,7 @@ RUN echo "import sys, re" > patch_vllm.py && \
echo "print('Successfully patched vLLM for R9700')" >> patch_vllm.py && \ echo "print('Successfully patched vLLM for R9700')" >> patch_vllm.py && \
python 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 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 ROCM_HOME="/opt/rocm"
ENV HIP_PATH="/opt/rocm" ENV HIP_PATH="/opt/rocm"
@@ -120,9 +109,6 @@ ENV HIP_ARCHITECTURES="gfx1201"
ENV AMDGPU_TARGETS="gfx1201" ENV AMDGPU_TARGETS="gfx1201"
ENV MAX_JOBS="32" 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 CC="/opt/rocm/llvm/bin/clang"
ENV CXX="/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 wheel --no-build-isolation --no-deps -w /tmp/dist -v . && \
python -m pip install /tmp/dist/*.whl python -m pip install /tmp/dist/*.whl
# --- bitsandbytes (ROCm) --- # bitsandbytes
WORKDIR /opt WORKDIR /opt
RUN proxychains git clone -b rocm_enabled_multi_backend https://github.com/ROCm/bitsandbytes.git RUN proxychains git clone -b rocm_enabled_multi_backend https://github.com/ROCm/bitsandbytes.git
WORKDIR /opt/bitsandbytes WORKDIR /opt/bitsandbytes
# Explicitly set HIP_PLATFORM (Docker ENV, not /etc/profile)
ENV HIP_PLATFORM="amd" ENV HIP_PLATFORM="amd"
ENV CMAKE_PREFIX_PATH="/opt/rocm" ENV CMAKE_PREFIX_PATH="/opt/rocm"
# Force CMake to use the System ROCm Compiler (/opt/rocm/llvm/bin/clang++)
RUN cmake -S . \ RUN cmake -S . \
-DGPU_TARGETS="gfx1201" \ -DGPU_TARGETS="gfx1201" \
-DBNB_ROCM_ARCH="gfx1201" \ -DBNB_ROCM_ARCH="gfx1201" \
@@ -153,7 +137,7 @@ RUN cmake -S . \
make -j$(nproc) && \ make -j$(nproc) && \
python -m pip install --no-cache-dir . --no-build-isolation --no-deps python -m pip install --no-cache-dir . --no-build-isolation --no-deps
# 8. Final Cleanup & Runtime # Cleanup
WORKDIR /opt WORKDIR /opt
RUN chmod -R a+rwX /opt && \ RUN chmod -R a+rwX /opt && \
find /opt/venv -type f -name "*.so" -exec strip -s {} + 2>/dev/null || true && \ 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 && \ rm -rf /root/.cache/pip || true && \
dnf clean all && rm -rf /var/cache/dnf/* 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/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/99-toolbox-banner.sh /etc/profile.d/99-toolbox-banner.sh
COPY scripts/zz-venv-last.sh /etc/profile.d/zz-venv-last.sh COPY scripts/zz-venv-last.sh /etc/profile.d/zz-venv-last.sh
+1 -1
View File
@@ -162,4 +162,4 @@ tcp_connect_time_out 8000
# meanwile # meanwile
# defaults set to "tor" # defaults set to "tor"
# socks4 127.0.0.1 9050 # socks4 127.0.0.1 9050
socks5 192.168.0.11 1080 socks5 127.0.0.1 1080
-7
View File
@@ -1,7 +0,0 @@
FROM registry.fedoraproject.org/fedora:43
RUN dnf -y install --setopt=install_weak_deps=False --nodocs proxychains curl && dnf clean all
COPY proxychains4.conf /etc/proxychains.conf
RUN proxychains curl -s https://www.google.com -o /dev/null && echo "SUCCESS: proxychains works!" || echo "FAILED: proxychains does not work"
-6
View File
@@ -1,6 +0,0 @@
FROM registry.fedoraproject.org/fedora:43
RUN dnf -y install --setopt=install_weak_deps=False --nodocs curl && dnf clean all
RUN curl -x socks5://192.168.0.11:1080 -s https://www.google.com -o /dev/null && echo "SOCKS5 SUCCESS" || echo "SOCKS5 FAILED"
RUN curl -x http://192.168.0.11:1080 -s https://www.google.com -o /dev/null && echo "HTTP SUCCESS" || echo "HTTP FAILED"
-9
View File
@@ -1,9 +0,0 @@
FROM registry.fedoraproject.org/fedora:43
RUN dnf -y install --setopt=install_weak_deps=False --nodocs curl && dnf clean all
RUN echo "=== Testing SOCKS5 ===" && \
curl -x socks5://192.168.0.11:1080 -v https://www.google.com 2>&1 | head -20 || echo "SOCKS5 FAILED"
RUN echo "=== Testing HTTP ===" && \
curl -x http://192.168.0.11:1080 -v https://www.google.com 2>&1 | head -20 || echo "HTTP FAILED"
-13
View File
@@ -1,13 +0,0 @@
FROM registry.fedoraproject.org/fedora:43
RUN dnf -y install --setopt=install_weak_deps=False --nodocs curl && dnf clean all
RUN echo "=== Test 1: Direct connection ===" && \
curl -s "https://therock-nightly-tarball.s3.amazonaws.com?list-type=2&prefix=therock-dist-linux-gfx120X-all-7" > /tmp/direct.xml && \
echo "Direct result size: $(wc -c < /tmp/direct.xml) bytes" && \
grep -o "therock-dist-linux-gfx120X-all-7[^\"]*\.tar\.gz" /tmp/direct.xml | head -5
RUN echo "=== Test 2: SOCKS5 proxy ===" && \
curl -x socks5://192.168.0.11:1080 -s "https://therock-nightly-tarball.s3.amazonaws.com?list-type=2&prefix=therock-dist-linux-gfx120X-all-7" > /tmp/proxy.xml && \
echo "Proxy result size: $(wc -c < /tmp/proxy.xml) bytes" && \
grep -o "therock-dist-linux-gfx120X-all-7[^\"]*\.tar\.gz" /tmp/proxy.xml | head -5