Spaces:
Sleeping
Sleeping
File size: 1,479 Bytes
37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 37b9169 b1d1ff4 | 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 | FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HF_HOME=/home/user/.cache/huggingface \
VISUALIZER_CONFIG=visualizer.hf.toml \
HOME=/home/user \
DEBIAN_FRONTEND=noninteractive
# Install Python and system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.10 \
python3.10-venv \
python3-pip \
git \
ffmpeg \
libglib2.0-0 \
libgomp1 \
build-essential && \
ln -sf /usr/bin/python3.10 /usr/bin/python3 && \
ln -sf /usr/bin/python3 /usr/bin/python && \
rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with UID 1000 for Hugging Face permissions
RUN useradd -m -u 1000 user
WORKDIR /app
# Copy requirements files first
COPY requirements-base.txt requirements-gpu-cu126.txt ./
# Install CUDA PyTorch/Torchvision first, then other base requirements
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements-gpu-cu126.txt
# Copy the rest of the application files
COPY --chown=user:1000 . .
# Create writable data directories and change ownership
RUN mkdir -p data/uploads data/jobs && \
chown -R user:1000 /app
# Switch to the non-root user
USER user
# Hugging Face Spaces expects the application on port 7860
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|