-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile-gpu
53 lines (41 loc) · 1.65 KB
/
Dockerfile-gpu
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
# Base image with NVIDIA CUDA
FROM nvidia/cuda:12.4.1-base-ubuntu20.04 as base
# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1
# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1
ENV RUNTIME docker
WORKDIR /app
# Install software-properties-common to add PPAs
RUN apt-get update && apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa
# Install Python, pip and other necessary packages
RUN apt-get install -y \
python3.11 \
python3-pip \
curl \
&& ln -s /usr/bin/python3.11 /usr/bin/python \
&& rm -rf /var/lib/apt/lists/*
# Make Python 3.11 the default Python version
RUN ln -sf /usr/bin/python3.11 /usr/bin/python3 && \
ln -sf /usr/bin/python3.11 /usr/bin/python
# Install UV
RUN curl -LsSf https://astral.sh/uv/0.2.1/install.sh | sh
# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/uv to speed up subsequent builds.
# Leverage a bind mount to requirements to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=requirements.lock,target=requirements.lock \
/root/.cargo/bin/uv pip install --system -r requirements.lock
# Install some executables
RUN apt-get update \
&& apt-get install -y curl procps sysstat ifstat \
&& rm -rf /var/lib/apt/lists/*
# Copy the source code into the container.
COPY src/ src/
COPY entrypoint.sh .
# Run the application.
ENTRYPOINT ["/app/entrypoint.sh"]