Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +42 -10
Dockerfile
CHANGED
|
@@ -1,25 +1,57 @@
|
|
| 1 |
-
# Stage 1: Builder
|
| 2 |
FROM python:3.8-bullseye as builder
|
| 3 |
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
-
build-essential
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY requirements.txt .
|
| 9 |
-
RUN pip install --
|
| 10 |
-
pip install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
# Stage 2:
|
| 13 |
FROM python:3.8-slim
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
RUN
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
WORKDIR /app
|
| 23 |
COPY . /app
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
CMD ["python", "train.py"]
|
|
|
|
| 1 |
+
# Stage 1: Builder with full compilation environment
|
| 2 |
FROM python:3.8-bullseye as builder
|
| 3 |
|
| 4 |
+
# Install comprehensive build tools
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
build-essential \
|
| 7 |
+
cmake \
|
| 8 |
+
git \
|
| 9 |
+
curl \
|
| 10 |
+
wget \
|
| 11 |
+
libopenblas-dev \
|
| 12 |
+
libssl-dev \
|
| 13 |
+
zlib1g-dev \
|
| 14 |
+
libbz2-dev \
|
| 15 |
+
libncurses5-dev \
|
| 16 |
+
libffi-dev \
|
| 17 |
+
liblzma-dev \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
# Create and use virtual environment
|
| 21 |
+
RUN python -m venv /opt/venv
|
| 22 |
+
ENV PATH="/opt/venv/bin:$PATH"
|
| 23 |
+
|
| 24 |
+
# Install packages with precise order and fallbacks
|
| 25 |
COPY requirements.txt .
|
| 26 |
+
RUN pip install --upgrade pip setuptools wheel && \
|
| 27 |
+
pip install torch==2.2.1 --index-url https://download.pytorch.org/whl/cpu && \
|
| 28 |
+
pip install ninja==1.11.1 && \
|
| 29 |
+
pip install transformers==4.38.2 && \
|
| 30 |
+
pip install accelerate==0.27.2 && \
|
| 31 |
+
pip install datasets==2.18.0 && \
|
| 32 |
+
pip install huggingface_hub==0.20.3 && \
|
| 33 |
+
{ pip install deepspeed==0.13.1 || pip install deepspeed==0.13.1 --no-deps; } && \
|
| 34 |
+
pip install unsloth==0.2.0 && \
|
| 35 |
+
{ pip install vllm==0.3.0 || pip install vllm==0.3.0 --no-deps; } && \
|
| 36 |
+
pip install fastapi==0.109.1 uvicorn==0.27.0
|
| 37 |
|
| 38 |
+
# Stage 2: Slim runtime image
|
| 39 |
FROM python:3.8-slim
|
| 40 |
|
| 41 |
+
# Copy virtual env from builder
|
| 42 |
+
COPY --from=builder /opt/venv /opt/venv
|
| 43 |
+
ENV PATH="/opt/venv/bin:$PATH"
|
| 44 |
|
| 45 |
+
# Install runtime dependencies only
|
| 46 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 47 |
+
libopenblas-base \
|
| 48 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 49 |
|
| 50 |
WORKDIR /app
|
| 51 |
COPY . /app
|
| 52 |
|
| 53 |
+
# Verify installation
|
| 54 |
+
RUN python -c "import torch; print(f'PyTorch {torch.__version__} installed')" && \
|
| 55 |
+
python -c "from transformers import __version__; print(f'Transformers {__version__} installed')"
|
| 56 |
+
|
| 57 |
CMD ["python", "train.py"]
|