# Base image with CUDA 12.2 FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 # System dependencies RUN apt-get update -q && \ apt-get install -y --no-install-recommends \ python3.9 \ python3-pip \ libgl1 \ libglib2.0-0 \ wget \ git \ && rm -rf /var/lib/apt/lists/* # CUDA/CuDNN setup with held packages override RUN wget -qO /tmp/cuda-keyring.deb \ https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ dpkg -i /tmp/cuda-keyring.deb && \ apt-get update -q && \ apt-get install -y --allow-change-held-packages --no-install-recommends \ libcudnn8=8.9.5.29-1+cuda12.2 \ libcublas-12-2=12.2.5.6-1 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create directories RUN mkdir -p /app/{weights,imgs} && \ chmod -R 777 /app # Application code COPY main.py utils.py download_models.py ./ COPY util ./util COPY weights ./weights # Download models RUN python3 download_models.py # Set up user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]