Skip to content

Commit 886e7c9

Browse files
committed
fix Dockerfile
1 parent 5549e64 commit 886e7c9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,34 @@ RUN pip install --upgrade pip setuptools wheel build scikit-build-core[pyproject
4949
# Copy source code to container
5050
COPY . .
5151

52+
# 🔧 设置 PyTorch 路径,让 CMake 能找到 Torch 配置
53+
# 获取 PyTorch 安装路径并设置 CMAKE_PREFIX_PATH
54+
RUN python -c "import torch; print(f'PyTorch installed at: {torch.__path__[0]}')" && \
55+
TORCH_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)") && \
56+
echo "Torch CMAKE path: $TORCH_PATH"
57+
5258
# Set environment variables for building
5359
ENV FLASH_ATTENTION_FORCE_BUILD=TRUE \
5460
FLASH_ATTENTION_DISABLE_BACKWARD=TRUE \
5561
CUDA_HOME=/usr/local/cuda \
5662
CUDA_ROOT=/usr/local/cuda
5763

64+
# 🎯 关键修复:设置 CMAKE_PREFIX_PATH 让 CMake 找到 PyTorch
65+
RUN TORCH_CMAKE_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)") && \
66+
echo "export CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH:\$CMAKE_PREFIX_PATH" >> ~/.bashrc && \
67+
echo "CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH" >> /etc/environment
68+
5869
# Create output directory
5970
RUN mkdir -p /out
6071

61-
# Build lightllm-kernel package (main project)
72+
# Build lightllm-kernel package (main project)
73+
# 🎯 关键:在构建时设置 CMAKE_PREFIX_PATH,让 CMake 找到 PyTorch
6274
RUN echo "🔧 Building lightllm-kernel package..." && \
63-
python -m build --wheel --outdir /out/ && \
75+
echo "📋 Verifying PyTorch installation..." && \
76+
python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); print(f'CMake prefix path: {torch.utils.cmake_prefix_path}')" && \
77+
TORCH_CMAKE_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)") && \
78+
echo "🔧 Setting CMAKE_PREFIX_PATH to: $TORCH_CMAKE_PATH" && \
79+
CMAKE_PREFIX_PATH="$TORCH_CMAKE_PATH:$CMAKE_PREFIX_PATH" python -m build --wheel --outdir /out/ && \
6480
echo "✅ lightllm-kernel build completed"
6581

6682
# Build flash_attn_3 package (hopper)

0 commit comments

Comments
 (0)