-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
77 lines (60 loc) · 2.82 KB
/
Copy pathDockerfile.gpu
File metadata and controls
77 lines (60 loc) · 2.82 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# syntax=docker/dockerfile:1.7
# GPU variant of the STT microservice.
# PyTorch cu118 is used for CUDA device detection; faster-whisper inference runs on
# CTranslate2 which requires CUDA 12 runtime libs (libcublas.so.12) from the base image.
# Builder and runtime both use nvidia/cuda:12.3.2-runtime-ubuntu22.04 so pip wheels
# and Python in /usr/local are compatible with glibc 2.35 (do not mix python:3.12-slim).
# Works on Pascal (GTX 1080 Ti, sm_61) and newer with driver >= 450.80.
# Usage: built automatically by docker-compose.gpu.yml overlay.
FROM nvidia/cuda:12.3.2-runtime-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
curl \
gcc \
libc6-dev \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-dev \
python3.12-venv \
&& curl -sSL https://bootstrap.pypa.io/get-pip.py | python3.12 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install shared worker library (provided via additional_contexts in compose)
COPY --from=shared . /tmp/dablja-worker
RUN python3.12 -m pip install --no-cache-dir /tmp/dablja-worker
COPY --from=segments . /tmp/dablja-segments
RUN python3.12 -m pip install --no-cache-dir /tmp/dablja-segments
# Install CUDA-enabled PyTorch first so device probing sees the GPU.
# cu118 binaries run on any driver >= 450.80 (CUDA 11.8 ABI).
RUN python3.12 -m pip install --no-cache-dir --timeout 600 --retries 3 \
"torch==2.2.0+cu118" \
--index-url https://download.pytorch.org/whl/cu118
# Remaining deps — requirements-base.txt intentionally omits torch (see requirements.txt).
COPY requirements-base.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
python3.12 -m pip install --default-timeout=600 --retries=3 -r requirements-base.txt
FROM nvidia/cuda:12.3.2-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
# Python 3.12 (deadsnakes) + FFmpeg; CUDA 12 runtime libs come from the base image.
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
curl \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
ffmpeg \
&& curl -sSL https://bootstrap.pypa.io/get-pip.py | python3.12 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /usr/local /usr/local
COPY . .
RUN rm -f app/dablja_worker.py
# Fail the build early if CTranslate2's required CUDA 12 libs are missing.
RUN python3.12 -c "import ctypes; ctypes.CDLL('libcublas.so.12'); print('libcublas OK')"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
EXPOSE 8001
CMD ["python3.12", "-m", "app.main"]