File size: 1,227 Bytes
ec855e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Dockerfile - GPU & CPU friendly image
# Uses NVIDIA CUDA runtime as base for GPU support. 
# Falls back to CPU automatically if no GPU is detected by the application.

FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04

# Prevent interactive prompts during apt-get
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Install Python and minimal system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \

    python3.11 \
    python3-pip \
    python3.11-dev \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Set python3.11 as the default python
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \

    && update-alternatives --set python3 /usr/bin/python3.11 \
    && python3 -m pip install --upgrade pip

# Copy requirements and install
# We install torch with cuda 12.1 index for explicit GPU support, but it works on CPU too.
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121

# Copy app code
COPY ./app /app/app

EXPOSE 7860

CMD ["python3", "-m", "app.main"]