Skip to content

Commit

Permalink
feat: add fly gpu dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Goller <[email protected]>
  • Loading branch information
goller committed Oct 9, 2024
1 parent 31cffcb commit a2d0173
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Dockerfile.flyio-gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM --platform=$TARGETPLATFORM ubuntu:22.04

ARG TARGETARCH
ARG BUILDKIT_VERSION
ARG BUILDKIT_PRIVATE_VERSION
ARG NYDUS_VERSION
ARG MACHINE_AGENT_VERSION
ARG CNI_VERSION

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update && \
apt-get install -y ca-certificates curl openssl htop wget git lsof fuse3 tar pigz e2fsprogs psmisc gpg && \
rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

RUN apt-get update && \
apt-get install -y nvidia-container-toolkit && \
rm -rf /var/lib/apt/lists/*

COPY ./config.toml /etc/nvidia-container-runtime/config.toml

# Required to expose the nvidia libraries to the container.
COPY ./nvidia.conf /etc/ld.so.conf.d/nvidia.conf
COPY ./entrypoint.sh /usr/bin/entrypoint.sh

RUN mkdir -p /etc/buildkit && \
curl -L "https://github.com/depot/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-${TARGETARCH}.tar.gz" | \
tar -zxv -C /usr/bin --strip-components=1

RUN mkdir -p /opt/buildkit-private/bin && \
curl -L "https://dl.depot.dev/buildkit-private/download/linux/$(uname -m)/${BUILDKIT_PRIVATE_VERSION}" | \
tar -zxv -C /opt/buildkit-private/bin --strip-components=1

RUN mkdir -p /opt/nydus && \
curl -L "https://github.com/dragonflyoss/nydus/releases/download/${NYDUS_VERSION}/nydus-static-${NYDUS_VERSION}-linux-${TARGETARCH}.tgz" | \
tar -zxv -C /opt/nydus --strip-components=1 && \
cp /opt/nydus/nydus* /usr/bin/


RUN curl -L "https://dl.depot.dev/machine-agent/download/linux/$(uname -m)/${MACHINE_AGENT_VERSION}" | \
tar -zxv --strip-components=1 --directory /usr/bin bin/machine-agent

RUN mkdir -p /opt/cni/bin/ && \
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${TARGETARCH}-${CNI_VERSION}.tgz" | \
tar -C /opt/cni/bin/ -zxv

ENTRYPOINT ["/usr/bin/entrypoint.sh"]
39 changes: 39 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#accept-nvidia-visible-devices-as-volume-mounts = false
#accept-nvidia-visible-devices-envvar-when-unprivileged = true
disable-require = false
supported-driver-capabilities = "compat32,compute,display,graphics,ngx,utility,video"
#swarm-resource = "DOCKER_RESOURCE_GPU"

[nvidia-container-cli]
debug = "/var/log/nvidia-container-toolkit.log"
environment = []
#ldcache = "/etc/ld.so.cache"
ldconfig = "@/sbin/ldconfig.real"
load-kmods = true
#no-cgroups = false
#path = "/usr/bin/nvidia-container-cli"
#root = "/run/nvidia/driver"
#user = "root:video"

[nvidia-container-runtime]
debug = "/var/log/nvidia-container-runtime.log"
log-level = "debug"
mode = "auto"
runtimes = ["docker-runc", "runc", "crun"]

[nvidia-container-runtime.modes]

[nvidia-container-runtime.modes.cdi]
annotation-prefixes = ["cdi.k8s.io/"]
default-kind = "nvidia.com/gpu"
spec-dirs = ["/etc/cdi", "/var/run/cdi"]

[nvidia-container-runtime.modes.csv]
mount-spec-path = "/etc/nvidia-container-runtime/host-files-for-container.d"

[nvidia-container-runtime-hook]
path = "nvidia-container-runtime-hook"
skip-mode-detection = false

[nvidia-ctk]
path = "nvidia-ctk"
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

/usr/sbin/ldconfig
/usr/bin/machine-agent
1 change: 1 addition & 0 deletions nvidia.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/lib/x86_64-linux-gnu

0 comments on commit a2d0173

Please sign in to comment.