Spaces:
Sleeping
Sleeping
File size: 987 Bytes
019b718 |
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 |
FROM python:3.10.12-slim
WORKDIR /app
# Set cache directories and performance optimizations
ENV HF_HOME=/tmp/.cache
ENV MPLCONFIGDIR=/tmp/.cache
ENV OMP_NUM_THREADS=4
ENV TOKENIZERS_PARALLELISM=false
# Install dependencies including CUDA support
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
libgomp1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create upload and output directories
RUN mkdir -p /tmp/uploads /tmp/outputs && chmod -R 777 /tmp/uploads /tmp/outputs
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create temporary cache directory (will be created at runtime)
RUN mkdir -p /tmp/.cache && chmod -R 777 /tmp/.cache
# Copy app code
COPY . .
# Set port
ENV PORT=7860
# Run with Gunicorn with optimized settings
CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--worker-class", "gthread", "--timeout", "300"]
|