x
This commit is contained in:
+57
-1
@@ -64,7 +64,8 @@ RUN sed -i 's|http://.*archive.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g'
|
|||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
# 补丁 1: hipcc/clang 符号链接(hipcc.pl 硬编码 clang-17,实际是 clang-22)
|
# 补丁 1: hipcc/clang 符号链接(hipcc.pl 硬编码 clang-17,实际是 clang-22)
|
||||||
ln -sf /usr/bin/hipvars.pm /usr/share/perl5/hipvars.pm && \
|
ln -sf /usr/bin/hipvars.pm /usr/share/perl5/hipvars.pm && \
|
||||||
ln -sf /usr/bin/hipcc.pl /opt/rocm/bin/hipcc && \
|
# hipcc.pl 在 WSL2 存在,原生 Linux 不存在;不存在时保留 apt 安装的版本
|
||||||
|
([ -f /usr/bin/hipcc.pl ] && ln -sf /usr/bin/hipcc.pl /opt/rocm/bin/hipcc) || echo "hipcc.pl not found, keeping apt-installed hipcc" && \
|
||||||
ln -sf /opt/rocm/llvm/bin/clang-22 /opt/rocm/llvm/bin/clang-17 && \
|
ln -sf /opt/rocm/llvm/bin/clang-22 /opt/rocm/llvm/bin/clang-17 && \
|
||||||
ln -sf /opt/rocm/llvm/bin/clang++ /opt/rocm/llvm/bin/clang++-17 && \
|
ln -sf /opt/rocm/llvm/bin/clang++ /opt/rocm/llvm/bin/clang++-17 && \
|
||||||
# 补丁 2: __hip_internal::conditional → std::conditional
|
# 补丁 2: __hip_internal::conditional → std::conditional
|
||||||
@@ -130,6 +131,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
rocblas-dev rocrand-dev hipfft-dev hipblaslt && \
|
rocblas-dev rocrand-dev hipfft-dev hipblaslt && \
|
||||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# ===========================================================================
|
||||||
|
# 阶段 6.5:安装 amdsmi(原生 Linux 必需,vllm 平台检测依赖)
|
||||||
|
# ===========================================================================
|
||||||
|
RUN if [ -d /opt/rocm/share/amd_smi ]; then \
|
||||||
|
cp -r /opt/rocm/share/amd_smi /opt/amd_smi && \
|
||||||
|
cd /opt/amd_smi && ${VENV}/bin/pip install --no-cache-dir . --no-build-isolation && \
|
||||||
|
echo "amdsmi installed."; \
|
||||||
|
else \
|
||||||
|
echo "amdsmi source not found, skipping."; \
|
||||||
|
fi
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
# 阶段 7:amd-aiter + flash_attn
|
# 阶段 7:amd-aiter + flash_attn
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
@@ -180,6 +192,14 @@ RUN set -ex && \
|
|||||||
printf 'include(/opt/rocm/lib/cmake/rocblas/rocblas-config.cmake)\nif(TARGET roc::rocblas AND NOT TARGET hip::hipblas)\n add_library(hip::hipblas ALIAS roc::rocblas)\nendif()\n' \
|
printf 'include(/opt/rocm/lib/cmake/rocblas/rocblas-config.cmake)\nif(TARGET roc::rocblas AND NOT TARGET hip::hipblas)\n add_library(hip::hipblas ALIAS roc::rocblas)\nendif()\n' \
|
||||||
> /opt/rocm/lib/cmake/hipblas/hipblas-config.cmake && \
|
> /opt/rocm/lib/cmake/hipblas/hipblas-config.cmake && \
|
||||||
# cmake 配置
|
# cmake 配置
|
||||||
|
# ---- 诊断 HIP cmake(构建成功后删除)----
|
||||||
|
echo "=== HIP cmake files ===" && \
|
||||||
|
(find /opt/rocm/lib/cmake -iname "*hip*" 2>/dev/null || true) && \
|
||||||
|
echo "=== All cmake packages ===" && \
|
||||||
|
(ls /opt/rocm/lib/cmake/ || true) && \
|
||||||
|
echo "=== hipcc check ===" && \
|
||||||
|
(which hipcc && hipcc --version || true) && \
|
||||||
|
echo "=== HIP diagnostic end ===" && \
|
||||||
mkdir -p /opt/vllm_build && \
|
mkdir -p /opt/vllm_build && \
|
||||||
cmake -S /opt/vllm -B /opt/vllm_build -G Ninja \
|
cmake -S /opt/vllm -B /opt/vllm_build -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
@@ -204,6 +224,42 @@ RUN set -ex && \
|
|||||||
cd /opt/vllm && ${VENV}/bin/pip install --no-cache-dir -e . --no-build-isolation && \
|
cd /opt/vllm && ${VENV}/bin/pip install --no-cache-dir -e . --no-build-isolation && \
|
||||||
# --no-build-isolation 可能漏装部分运行时依赖,显式补装
|
# --no-build-isolation 可能漏装部分运行时依赖,显式补装
|
||||||
${VENV}/bin/pip install --no-cache-dir regex && \
|
${VENV}/bin/pip install --no-cache-dir regex && \
|
||||||
|
# ---- 补丁 6:vllm 平台检测 —— torch.version.hip 回退 ----
|
||||||
|
${VENV}/bin/python -c "
|
||||||
|
import re
|
||||||
|
f = '/opt/vllm/vllm/platforms/__init__.py'
|
||||||
|
c = open(f).read()
|
||||||
|
old = \" return 'vllm.platforms.rocm.RocmPlatform' if is_rocm else None\"
|
||||||
|
new = ''' # amdsmi fallback: also check torch.version.hip
|
||||||
|
if not is_rocm:
|
||||||
|
try:
|
||||||
|
import torch
|
||||||
|
if torch.version.hip is not None:
|
||||||
|
is_rocm = True
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return 'vllm.platforms.rocm.RocmPlatform' if is_rocm else None'''
|
||||||
|
c2 = c.replace(old, new)
|
||||||
|
if c2 != c:
|
||||||
|
open(f, 'w').write(c2)
|
||||||
|
print('Patch 6: __init__.py platform fallback applied.')
|
||||||
|
else:
|
||||||
|
print('Patch 6: already applied or pattern not found.')
|
||||||
|
" && \
|
||||||
|
# ---- 补丁 7:vllm rocm.py 断开循环导入 ----
|
||||||
|
${VENV}/bin/python -c "
|
||||||
|
f = '/opt/vllm/vllm/platforms/rocm.py'
|
||||||
|
c = open(f).read()
|
||||||
|
# 替换 logger.warning_once( 为 sys.stderr.write(
|
||||||
|
old = 'logger.warning_once('
|
||||||
|
new = 'import sys as _sys\n _sys.stderr.write('
|
||||||
|
c2 = c.replace(old, new)
|
||||||
|
if c2 != c:
|
||||||
|
open(f, 'w').write(c2)
|
||||||
|
print('Patch 7: rocm.py logger.warning_once → sys.stderr.write applied.')
|
||||||
|
else:
|
||||||
|
print('Patch 7: already applied or pattern not found.')
|
||||||
|
" && \
|
||||||
# 验证 PyTorch 没被 vllm 依赖覆盖
|
# 验证 PyTorch 没被 vllm 依赖覆盖
|
||||||
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten by vllm deps: {v}'; print('PyTorch OK:', v)" && \
|
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten by vllm deps: {v}'; print('PyTorch OK:', v)" && \
|
||||||
# 先重装 ROCm PyTorch 覆盖可能的 CUDA 版,再清理 CUDA triton 元数据
|
# 先重装 ROCm PyTorch 覆盖可能的 CUDA 版,再清理 CUDA triton 元数据
|
||||||
|
|||||||
Reference in New Issue
Block a user