From b8999eef4656c138fba61ae6787ed07e3e429c25 Mon Sep 17 00:00:00 2001 From: chenjw28 <792430652@qq.com> Date: Thu, 4 Jun 2026 16:09:06 +0800 Subject: [PATCH] x --- docker/Dockerfile | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1e3a313..983749a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -225,12 +225,12 @@ RUN set -ex && \ # --no-build-isolation 可能漏装部分运行时依赖,显式补装 ${VENV}/bin/pip install --no-cache-dir regex && \ # ---- 补丁 6:vllm 平台检测 —— torch.version.hip 回退 ---- - ${VENV}/bin/python -c " + cat > /tmp/patch6.py << 'PYEOF' 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 +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 @@ -238,28 +238,24 @@ new = ''' # amdsmi fallback: also check torch.version.hip is_rocm = True except Exception: pass - return 'vllm.platforms.rocm.RocmPlatform' if is_rocm else None''' + 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.') -" && \ +if c2 != c: open(f, 'w').write(c2); print('Patch 6 applied.') +else: print('Patch 6 already applied.') +PYEOF + ${VENV}/bin/python /tmp/patch6.py && \ # ---- 补丁 7:vllm rocm.py 断开循环导入 ---- - ${VENV}/bin/python -c " + cat > /tmp/patch7.py << 'PYEOF' 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.') -" && \ +if c2 != c: open(f, 'w').write(c2); print('Patch 7 applied.') +else: print('Patch 7 already applied.') +PYEOF + ${VENV}/bin/python /tmp/patch7.py && \ + rm -f /tmp/patch6.py /tmp/patch7.py && \ # 验证 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)" && \ # 先重装 ROCm PyTorch 覆盖可能的 CUDA 版,再清理 CUDA triton 元数据