-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
53 lines (40 loc) · 1.36 KB
/
Dockerfile.gpu
File metadata and controls
53 lines (40 loc) · 1.36 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
# syntax=docker/dockerfile:1.6
############################
# Builder: install deps with uv (GPU-enabled)
############################
FROM python:3.11-slim AS builder
# System deps (add more if you need: git, build-essential, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install uv
RUN pip install --no-cache-dir uv
# Copy only dependency metadata first for better layer caching
COPY pyproject.toml ./
COPY uv.lock ./
# Create a virtualenv and sync deps from lockfile, including CUDA extra
# --frozen: fail if lockfile doesn't match pyproject
RUN uv venv /opt/venv && \
. /opt/venv/bin/activate && \
uv sync --active --frozen --no-dev --extra cuda12
############################
# Runtime: copy venv + code
############################
FROM python:3.11-slim AS runtime
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
# NVIDIA runtime hints (GPU is still assigned at `docker run --gpus ...`)
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
WORKDIR /app
# Copy venv from builder
COPY --from=builder /opt/venv /opt/venv
# Copy repo contents
COPY . /app
# Default help
CMD ["python", "-c", "print('GPU container ready. Try: python scripts/measure_similarity.py')"]