@@ -7,20 +7,15 @@ ARG TARGETPLATFORM
77ENV PATH=/opt/conda/bin:$PATH \
88 CONDA_PREFIX=/opt/conda
99
10- # Install system dependencies
1110RUN chmod 777 -R /tmp && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
1211 ca-certificates \
1312 libssl-dev \
1413 curl \
1514 g++ \
1615 make \
17- git \
18- cmake \
19- ninja-build \
20- build-essential && \
16+ git && \
2117 rm -rf /var/lib/apt/lists/*
2218
23- # Install Mambaforge
2419RUN case ${TARGETPLATFORM} in \
2520 "linux/arm64" ) MAMBA_ARCH=aarch64 ;; \
2621 *) MAMBA_ARCH=x86_64 ;; \
@@ -29,24 +24,18 @@ RUN case ${TARGETPLATFORM} in \
2924 bash ~/mambaforge.sh -b -p /opt/conda && \
3025 rm ~/mambaforge.sh
3126
32- # Install Python
3327RUN case ${TARGETPLATFORM} in \
3428 "linux/arm64" ) exit 1 ;; \
3529 *) /opt/conda/bin/conda update -y conda && \
3630 /opt/conda/bin/conda install -y "python=${PYTHON_VERSION}" ;; \
3731 esac && \
3832 /opt/conda/bin/conda clean -ya
3933
40- # Set working directory
41- WORKDIR /workspace
4234
43- # Install PyTorch with CUDA support
44- RUN pip install torch==2.7.1
35+ WORKDIR /root
4536
46- # Install build dependencies
47- RUN pip install --upgrade pip setuptools wheel build scikit-build-core[pyproject] pybind11 ninja
37+ RUN pip install torch==2.7.1
4838
49- # Copy source code to container
5039COPY . .
5140
5241# 🔧 设置 PyTorch 路径,让 CMake 能找到 Torch 配置
@@ -55,18 +44,14 @@ RUN python -c "import torch; print(f'PyTorch installed at: {torch.__path__[0]}')
5544 TORCH_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)" ) && \
5645 echo "Torch CMAKE path: $TORCH_PATH"
5746
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 \
47+ ENV CUDA_HOME=/usr/local/cuda \
6248 CUDA_ROOT=/usr/local/cuda
6349
6450# 🎯 关键修复:设置 CMAKE_PREFIX_PATH 让 CMake 找到 PyTorch
6551RUN TORCH_CMAKE_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)" ) && \
6652 echo "export CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH:\$ CMAKE_PREFIX_PATH" >> ~/.bashrc && \
6753 echo "CMAKE_PREFIX_PATH=$TORCH_CMAKE_PATH" >> /etc/environment
6854
69- # Create output directory
7055RUN mkdir -p /out
7156
7257# Build lightllm-kernel package (main project)
@@ -82,17 +67,6 @@ RUN echo "🔧 Building lightllm-kernel package..." && \
8267# Build flash_attn_3 package (hopper)
8368RUN echo "🔧 Building flash_attn_3 package..." && \
8469 cd flash-attention/hopper && \
85- MAX_JOBS=2 NVCC_THREADS=2 FLASH_ATTN_CUDA_ARCHS=90 python setup.py bdist_wheel && \
70+ MAX_JOBS=1 NVCC_THREADS=1 FLASH_ATTN_CUDA_ARCHS=90 FLASH_ATTENTION_DISABLE_SM80=TRUE python setup.py bdist_wheel && \
8671 cp dist/*.whl /out/ && \
8772 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