Docker Image with Pytorch | Imagem Docker com Pytorch
171
Docker Image with PyTorch and UV,a package installer. The Docker images in this repository were created as part of building a continuous integration and delivery (CI/CD) template for projects requiring GPU support, with fixed versions of PyTorch and CUDA. The primary focus of this project is the development of the CI/CD template itself. However, one of its future goals is to enhance the continuous delivery pipeline, enabling the creation of Docker images for various combinations of PyTorch and CUDA versions. For more details about the image check the image's GitHub repository.
To connect to the Container's shell, run
docker run --gpus all -ti --rm carloscaldeira/pytorch:2.5.1-cuda12.4-uv-development
To use it in a Dockerfile, add
FROM carloscaldeira/pytorch:2.5.1-cuda12.4-uv-development
These images pertain to two environments: the development environment includes PyTorch and CUDA, as well as the UV Python package installer. The second image (runtime) excludes UV, retaining only the pre-installed Python packages to reduce its size, demonstrating how a runtime image could be generated from the development image in a CI/CD pipeline. To install additional libraries beyond PyTorch with CUDA, you can base your Dockerfile on the development image. Below you can view the Dockerfile used:
FROM ubuntu:22.04 AS base
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
gcc && \
apt-get clean && rm -rf /var/lib/apt/lists/*
FROM base AS development
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
build-essential && \
rm -rf /var/lib/apt/lists/*
ADD https://astral.sh/uv/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh
ENV PATH="/root/.local/bin/:$PATH"
RUN uv python install 3.12
WORKDIR /app
COPY uv.lock* pyproject.toml .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --extra torch2.5.1-cu124 --no-install-project --no-dev
FROM base AS runtime
COPY --from=development /root/.local/share/uv/python/ /root/.local/share/uv/python/
COPY --from=development /app/.venv/ /app/.venv/
WORKDIR /app
COPY /src/ ./src/
Content type
Image
Digest
sha256:af4f67007…
Size
3 GB
Last updated
over 1 year ago
docker pull carloscaldeira/pytorch:2.5.1-cuda12.4-uv-runtime