@@ -7,6 +7,7 @@ ARG TARGETPLATFORM
77ENV PATH=/opt/conda/bin:$PATH \
88 CONDA_PREFIX=/opt/conda
99
10+ # Install system dependencies
1011RUN chmod 777 -R /tmp && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
1112 ca-certificates \
1213 libssl-dev \
@@ -19,6 +20,7 @@ RUN chmod 777 -R /tmp && apt-get update && DEBIAN_FRONTEND=noninteractive apt-ge
1920 build-essential && \
2021 rm -rf /var/lib/apt/lists/*
2122
23+ # Install Mambaforge
2224RUN case ${TARGETPLATFORM} in \
2325 "linux/arm64" ) MAMBA_ARCH=aarch64 ;; \
2426 *) MAMBA_ARCH=x86_64 ;; \
@@ -27,18 +29,24 @@ RUN case ${TARGETPLATFORM} in \
2729 bash ~/mambaforge.sh -b -p /opt/conda && \
2830 rm ~/mambaforge.sh
2931
32+ # Install Python
3033RUN case ${TARGETPLATFORM} in \
3134 "linux/arm64" ) exit 1 ;; \
3235 *) /opt/conda/bin/conda update -y conda && \
3336 /opt/conda/bin/conda install -y "python=${PYTHON_VERSION}" ;; \
3437 esac && \
3538 /opt/conda/bin/conda clean -ya
3639
40+ # Set working directory
41+ WORKDIR /workspace
3742
38- WORKDIR /root
43+ # Install PyTorch with CUDA support
44+ RUN pip install torch==2.7.1
3945
40- RUN pip install torch==2.7.1 numpy
46+ # Install build dependencies
47+ RUN pip install --upgrade pip setuptools wheel build scikit-build-core[pyproject] pybind11 ninja
4148
49+ # Copy source code to container
4250COPY . .
4351
4452# 🔧 设置 PyTorch 路径,让 CMake 能找到 Torch 配置
@@ -47,14 +55,18 @@ RUN python -c "import torch; print(f'PyTorch installed at: {torch.__path__[0]}')
4755 TORCH_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)" ) && \
4856 echo "Torch CMAKE path: $TORCH_PATH"
4957
50- ENV CUDA_HOME=/usr/local/cuda \
58+ # Set environment variables for building
59+ ENV FLASH_ATTENTION_FORCE_BUILD=TRUE \
60+ FLASH_ATTENTION_DISABLE_BACKWARD=TRUE \
61+ CUDA_HOME=/usr/local/cuda \
5162 CUDA_ROOT=/usr/local/cuda
5263
5364# 🎯 关键修复:设置 CMAKE_PREFIX_PATH 让 CMake 找到 PyTorch
5465RUN TORCH_CMAKE_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)" ) && \
5566 echo "export CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH:\$ CMAKE_PREFIX_PATH" >> ~/.bashrc && \
5667 echo "CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH" >> /etc/environment
5768
69+ # Create output directory
5870RUN mkdir -p /out
5971
6072# Build lightllm-kernel package (main project)
@@ -70,6 +82,17 @@ RUN echo "🔧 Building lightllm-kernel package..." && \
7082# Build flash_attn_3 package (hopper)
7183RUN echo "🔧 Building flash_attn_3 package..." && \
7284 cd flash-attention/hopper && \
73- MAX_JOBS=1 NVCC_THREADS=1 FLASH_ATTN_CUDA_ARCHS=90 FLASH_ATTENTION_DISABLE_SM80=TRUE python setup.py bdist_wheel && \
85+ MAX_JOBS=2 NVCC_THREADS=2 FLASH_ATTN_CUDA_ARCHS=90 FLASH_ATTENTION_DISABLE_SM80=TRUE python setup.py bdist_wheel && \
7486 cp dist/*.whl /out/ && \
7587 echo "✅ flash_attn_3 build completed"
88+
89+ # Verify all wheels are built
90+ RUN echo "📦 Final wheel packages:" && \
91+ ls -la /out/ && \
92+ WHEEL_COUNT=$(ls -1 /out/*.whl | wc -l) && \
93+ echo "Total wheels built: $WHEEL_COUNT" && \
94+ if [ "$WHEEL_COUNT" -ne 2 ]; then \
95+ echo "❌ Error: Expected 2 wheels, found $WHEEL_COUNT" && exit 1; \
96+ else \
97+ echo "✅ Successfully built all wheel packages" ; \
98+ fi
0 commit comments