Fix flash-attn build: install with --no-build-isolation so it can access torch
Browse files- Dockerfile +10 -4
- requirements.txt +2 -6
Dockerfile
CHANGED
|
@@ -30,12 +30,18 @@ RUN echo "⏱️ [BUILD] Installing ESPnet dependencies..." && \
|
|
| 30 |
pip install --no-cache-dir -r /tmp/requirements-espnet.txt && \
|
| 31 |
echo "✅ [BUILD] ESPnet dependencies installed"
|
| 32 |
|
| 33 |
-
# Stage 3: Remaining dependencies
|
| 34 |
-
# IMPORTANT: torch is already installed from base, so flash-attn can build
|
| 35 |
COPY requirements.txt /tmp/requirements.txt
|
| 36 |
-
RUN echo "⏱️ [BUILD] Installing remaining dependencies
|
| 37 |
pip install --no-cache-dir -r /tmp/requirements.txt && \
|
| 38 |
-
echo "✅ [BUILD]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Set up app directory
|
| 41 |
WORKDIR /app
|
|
|
|
| 30 |
pip install --no-cache-dir -r /tmp/requirements-espnet.txt && \
|
| 31 |
echo "✅ [BUILD] ESPnet dependencies installed"
|
| 32 |
|
| 33 |
+
# Stage 3: Remaining dependencies (excluding flash-attn)
|
|
|
|
| 34 |
COPY requirements.txt /tmp/requirements.txt
|
| 35 |
+
RUN echo "⏱️ [BUILD] Installing remaining dependencies..." && \
|
| 36 |
pip install --no-cache-dir -r /tmp/requirements.txt && \
|
| 37 |
+
echo "✅ [BUILD] Remaining dependencies installed"
|
| 38 |
+
|
| 39 |
+
# Stage 4: Install flash-attn separately with --no-build-isolation
|
| 40 |
+
# flash-attn needs torch to be available during build, but pip's build isolation
|
| 41 |
+
# prevents it from seeing installed packages. --no-build-isolation fixes this.
|
| 42 |
+
RUN echo "⏱️ [BUILD] Installing Flash Attention (compilation may take 5-15 minutes)..." && \
|
| 43 |
+
pip install --no-cache-dir --no-build-isolation flash-attn>=2.3.0 && \
|
| 44 |
+
echo "✅ [BUILD] Flash Attention installed"
|
| 45 |
|
| 46 |
# Set up app directory
|
| 47 |
WORKDIR /app
|
requirements.txt
CHANGED
|
@@ -1,13 +1,9 @@
|
|
| 1 |
# Remaining dependencies not in requirements-base.txt or requirements-espnet.txt
|
| 2 |
# These are installed after base and ESPnet for optimal caching
|
| 3 |
-
# NOTE:
|
| 4 |
jiwer>=3.0.0
|
| 5 |
|
| 6 |
# Build dependencies for Flash Attention compilation
|
|
|
|
| 7 |
packaging>=21.0
|
| 8 |
ninja>=1.10.0
|
| 9 |
-
|
| 10 |
-
# Flash Attention - optimized for NVIDIA A10G GPUs (Ampere architecture)
|
| 11 |
-
# Required for best performance on HF Spaces with GPU
|
| 12 |
-
# NOTE: torch must be installed first (from requirements-base.txt) for flash-attn to build
|
| 13 |
-
flash-attn>=2.3.0
|
|
|
|
| 1 |
# Remaining dependencies not in requirements-base.txt or requirements-espnet.txt
|
| 2 |
# These are installed after base and ESPnet for optimal caching
|
| 3 |
+
# NOTE: flash-attn is installed separately in Dockerfile with --no-build-isolation
|
| 4 |
jiwer>=3.0.0
|
| 5 |
|
| 6 |
# Build dependencies for Flash Attention compilation
|
| 7 |
+
# (flash-attn itself is installed separately in Dockerfile)
|
| 8 |
packaging>=21.0
|
| 9 |
ninja>=1.10.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|