diff --git a/Dockerfile b/Dockerfile index 30a4bc1..7c570f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/proxychains4.conf b/proxychains4.conf index bc7003e..1e0c7fb 100644 --- a/proxychains4.conf +++ b/proxychains4.conf @@ -162,4 +162,4 @@ tcp_connect_time_out 8000 # meanwile # defaults set to "tor" # socks4 127.0.0.1 9050 -socks5 192.168.0.11 1080 +socks5 127.0.0.1 1080 diff --git a/test_proxy.Dockerfile b/test_proxy.Dockerfile deleted file mode 100644 index aaaef84..0000000 --- a/test_proxy.Dockerfile +++ /dev/null @@ -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" diff --git a/test_proxy2.Dockerfile b/test_proxy2.Dockerfile deleted file mode 100644 index bcedaa0..0000000 --- a/test_proxy2.Dockerfile +++ /dev/null @@ -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" diff --git a/test_proxy3.Dockerfile b/test_proxy3.Dockerfile deleted file mode 100644 index 7bf7089..0000000 --- a/test_proxy3.Dockerfile +++ /dev/null @@ -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" diff --git a/test_s3.Dockerfile b/test_s3.Dockerfile deleted file mode 100644 index eff14f2..0000000 --- a/test_s3.Dockerfile +++ /dev/null @@ -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