Skip to content

Commit 9547688

Browse files
authored
Merge pull request #264 from NVIDIA/added-devcontainer
Added devcontainer
2 parents 757e7e7 + 542bf34 commit 9547688

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.devcontainer/Dockerfile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

.devcontainer/devcontainer.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Read here https://containers.dev/implementors/json_reference/
2+
{
3+
"name": "dcgm-exporter-container",
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
"privileged": true,
8+
"runArgs": [
9+
"-v", "/run/docker.sock:/run/docker.sock:rw",
10+
"--mount", "type=bind,src=${env:HOME}/.ssh,dst=/home/developer/.ssh",
11+
"-p", "2222:22",
12+
"--name", "vscode_dev_container",
13+
"-e", "DCGM_BUILD_INSIDE_DOCKER=1",
14+
"-e", "NVIDIA_DRIVER_CAPABILITIES=compute,utility",
15+
"-e", "NVIDIA_VISIBLE_DEVICES=ALL",
16+
"--cap-add=SYS_ADMIN",
17+
"--security-opt",
18+
"seccomp=unconfined",
19+
"--gpus=all"
20+
]
21+
}

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ validate-modules:
9292
@echo "- Checking for any unused/missing packages in go.mod..."
9393
go mod tidy
9494
@git diff --exit-code -- go.sum go.mod
95+
96+
.PHONY: tools
97+
tools: ## Install required tools and utilities
98+
go install github.com/golangci/golangci-lint/cmd/[email protected]

0 commit comments

Comments
 (0)