Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce CUDA images size #2724

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ npm-debug.log
/assets/node_modules/
/tmp/
/livebook
# Ignore app release files, including build artifacts
/rel/app
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ RUN mix do compile, release livebook
# Consequently the release doesn't include ERTS as we have it anyway.
FROM ${BASE_IMAGE}

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
# Runtime dependencies
Expand Down
33 changes: 14 additions & 19 deletions docker/base/elixir-cuda.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ ARG ELIXIR_VERSION
ARG ERLANG_VERSION
ARG UBUNTU_VERSION

ARG CUDA_VERSION

FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-ubuntu-${UBUNTU_VERSION} AS elixir

FROM nvidia/cuda:${CUDA_VERSION}-cudnn8-devel-ubuntu20.04
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-ubuntu-${UBUNTU_VERSION}

ENV DEBIAN_FRONTEND nonintaeractive
ENV LANG=C.UTF-8

# Erlang runtime dependencies, see https://github.com/hexpm/bob/blob/3b5721dccdfe9d59766f374e7b4fb7fb8a7c720e/priv/scripts/docker/erlang-ubuntu-focal.dockerfile#L41-L45
RUN apt-get update && \
apt-get -y --no-install-recommends install \
libodbc1 \
libssl1.1 \
libsctp1
ARG CUDA_VERSION

# We copy the top-level directory first to preserve symlinks in /usr/local/bin
COPY --from=elixir /usr/local /usr/ELIXIR_LOCAL
RUN distro="ubuntu$(. /etc/lsb-release; echo "$DISTRIB_RELEASE" | tr -d '.')" && \
# Official Docker images use the sbsa packages when targetting arm64.
# See https://gitlab.com/nvidia/container-images/cuda/-/blob/85f465ea3343a2d7f7753a0a838701999ed58a01/dist/12.5.1/ubuntu2204/base/Dockerfile#L12
arch="$(if [ "$(uname -m)" = "aarch64" ]; then echo "sbsa"; else echo "x86_64"; fi)" && \
apt update -q && apt install -y ca-certificates wget && \
wget -qO /tmp/cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-keyring_1.1-1_all.deb && \
dpkg -i /tmp/cuda-keyring.deb && apt update -q

RUN cp -r /usr/ELIXIR_LOCAL/lib/* /usr/local/lib && \
cp -r /usr/ELIXIR_LOCAL/bin/* /usr/local/bin && \
rm -rf /usr/ELIXIR_LOCAL
# In order to minimize the image size, we install only a subset of
# the CUDA toolkit that is required by Elixir numerical packages
# (nvcc and runtime libraries). Note that we do not need to install
# the driver, it is already provided by NVIDIA Container Toolkit.
RUN apt install -y git cuda-nvcc-${CUDA_VERSION} cuda-libraries-${CUDA_VERSION} libcudnn8
2 changes: 1 addition & 1 deletion docker/build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ -z "$livebook_version" ]; then
fi

cuda_tag_list=("cuda11.8" "cuda12.1")
cuda_version_list=("11.8.0" "12.1.0")
cuda_version_list=("11-8" "12-1")

for idx in "${!cuda_tag_list[@]}"; do
cuda_tag="${cuda_tag_list[idx]}"
Expand Down
2 changes: 1 addition & 1 deletion versions
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ otp="27.0"
openssl="1.1.1s"
rebar3="3.22.0"
debian="bookworm-20240701-slim"
ubuntu="focal-20240530"
ubuntu="jammy-20240530"
Loading