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