- Don't pin exact torch/torchaudio/torchvision versions (use >=2.1.0) - Install CUDA PyTorch first in Docker before other requirements - Upgrade pip before installations to avoid compatibility issues - Let pip resolve latest compatible versions from cu118 index
55 lines
1.7 KiB
Docker
55 lines
1.7 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies including CUDA-related packages
|
|
RUN apt-get update && apt-get install -y \
|
|
ffmpeg \
|
|
git \
|
|
wget \
|
|
curl \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for better Docker layer caching
|
|
COPY requirements.txt .
|
|
|
|
# Upgrade pip first to avoid installation issues
|
|
RUN pip install --upgrade pip
|
|
|
|
# Install CUDA-optimized PyTorch FIRST (before other requirements)
|
|
# Using latest versions from cu118 index for SpeechBrain 1.0 / pyannote diarization compatibility
|
|
# Not pinning versions - pip will resolve latest compatible versions from the index
|
|
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
|
|
|
# Install remaining dependencies from requirements.txt
|
|
# Skip torch/torchvision/torchaudio since they're already installed
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create directories for mounted volumes
|
|
RUN mkdir -p /app/data/videos /app/data/outputs /app/data/cache
|
|
|
|
# Set environment variables
|
|
ENV STREAMLIT_SERVER_PORT=8501
|
|
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
|
ENV STREAMLIT_SERVER_HEADLESS=true
|
|
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
|
|
|
# GPU-specific environment variables
|
|
ENV CUDA_VISIBLE_DEVICES=0
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
|
|
|
# Expose Streamlit port
|
|
EXPOSE 8501
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD curl -f http://localhost:8501/_stcore/health || exit 1
|
|
|
|
# Start the application
|
|
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] |