1
+ FROM nvcr.io/nvidia/cuda:12.3.1-base-ubuntu22.04
2
+ ARG GOLANG_VERSION=1.21.5
3
+ ARG USERNAME=developer
4
+ ARG USER_UID=1000
5
+ ARG USER_GID=1000
6
+ ARG DCGM_VERSION=3.3.3
7
+ # Create a user 'developer' with UID=1000, add to 'developer' group, and add to 'sudo' group
8
+ RUN groupadd -g $USER_GID $USERNAME && \
9
+ useradd -m -u $USER_GID -g $USERNAME -s /bin/bash $USERNAME && \
10
+ usermod -aG sudo $USERNAME
11
+ # Allow 'developer' to use sudo without a password
12
+ RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
13
+
14
+ RUN --mount=type=cache,target=/var/cache/apt \
15
+ set -eux; \
16
+ apt-get update; \
17
+ apt-get install -y --no-install-recommends \
18
+ git \
19
+ ca-certificates \
20
+ g++ \
21
+ gcc \
22
+ libc6-dev \
23
+ make \
24
+ pkg-config \
25
+ wget \
26
+ datacenter-gpu-manager=1:${DCGM_VERSION} \
27
+ libcap2-bin \
28
+ && apt-get autoremove -y \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ RUN set -eux; \
32
+ arch="$(dpkg --print-architecture)" ; arch="${arch##*-}" ; \
33
+ url=; \
34
+ echo "$arch" ; \
35
+ case "$arch" in \
36
+ 'amd64' ) \
37
+ url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz" ; \
38
+ ;; \
39
+ 'arm64' ) \
40
+ url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-arm64.tar.gz" ; \
41
+ ;; \
42
+ *) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)" ; exit 1 ;; \
43
+ esac; \
44
+ build=; \
45
+ if [ -z "$url" ]; then \
46
+ # https://github.com/golang/go/issues/38536#issuecomment-616897960
47
+ build=1; \
48
+ url="https://dl.google.com/go/go${GOLANG_VERSION}.src.tar.gz" ; \
49
+ echo >&2; \
50
+ echo >&2 "warning: current architecture ($arch) does not have a compatible Go binary release; will be building from source" ; \
51
+ echo >&2; \
52
+ fi; \
53
+ wget -O go.tgz "$url" --progress=dot:giga; \
54
+ tar -C /usr/local -xzf go.tgz; \
55
+ rm go.tgz
56
+ ENV GOTOOLCHAIN=local
57
+ ENV GOPATH /go
58
+ ENV PATH $GOPATH/bin:$PATH
59
+ RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH"
60
+ ENV PATH $PATH:/usr/local/go/bin
61
+
62
+ RUN rm -rfd /usr/local/dcgm/bindings /usr/local/dcgm/sdk_samples /usr/share/nvidia-validation-suite
63
+ # Required for DCP metrics
64
+ ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,compat32
65
+ # disable all constraints on the configurations required by NVIDIA container toolkit
66
+ ENV NVIDIA_DISABLE_REQUIRE="true"
67
+ ENV NVIDIA_VISIBLE_DEVICES=all
0 commit comments