-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from NVIDIA/added-devcontainer
Added devcontainer
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
FROM nvcr.io/nvidia/cuda:12.3.1-base-ubuntu22.04 | ||
ARG GOLANG_VERSION=1.21.5 | ||
ARG USERNAME=developer | ||
ARG USER_UID=1000 | ||
ARG USER_GID=1000 | ||
ARG DCGM_VERSION=3.3.3 | ||
# Create a user 'developer' with UID=1000, add to 'developer' group, and add to 'sudo' group | ||
RUN groupadd -g $USER_GID $USERNAME && \ | ||
useradd -m -u $USER_GID -g $USERNAME -s /bin/bash $USERNAME && \ | ||
usermod -aG sudo $USERNAME | ||
# Allow 'developer' to use sudo without a password | ||
RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
git \ | ||
ca-certificates \ | ||
g++ \ | ||
gcc \ | ||
libc6-dev \ | ||
make \ | ||
pkg-config \ | ||
wget \ | ||
datacenter-gpu-manager=1:${DCGM_VERSION} \ | ||
libcap2-bin \ | ||
&& apt-get autoremove -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN set -eux; \ | ||
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ | ||
url=; \ | ||
echo "$arch"; \ | ||
case "$arch" in \ | ||
'amd64') \ | ||
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \ | ||
;; \ | ||
'arm64') \ | ||
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \ | ||
;; \ | ||
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \ | ||
esac; \ | ||
build=; \ | ||
if [ -z "$url" ]; then \ | ||
# https://github.com/golang/go/issues/38536#issuecomment-616897960 | ||
build=1; \ | ||
url="https://dl.google.com/go/go${GOLANG_VERSION}.src.tar.gz"; \ | ||
echo >&2; \ | ||
echo >&2 "warning: current architecture ($arch) does not have a compatible Go binary release; will be building from source"; \ | ||
echo >&2; \ | ||
fi; \ | ||
wget -O go.tgz "$url" --progress=dot:giga; \ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz | ||
ENV GOTOOLCHAIN=local | ||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$PATH | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH" | ||
ENV PATH $PATH:/usr/local/go/bin | ||
|
||
RUN rm -rfd /usr/local/dcgm/bindings /usr/local/dcgm/sdk_samples /usr/share/nvidia-validation-suite | ||
# Required for DCP metrics | ||
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,compat32 | ||
# disable all constraints on the configurations required by NVIDIA container toolkit | ||
ENV NVIDIA_DISABLE_REQUIRE="true" | ||
ENV NVIDIA_VISIBLE_DEVICES=all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Read here https://containers.dev/implementors/json_reference/ | ||
{ | ||
"name": "dcgm-exporter-container", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"privileged": true, | ||
"runArgs": [ | ||
"-v", "/run/docker.sock:/run/docker.sock:rw", | ||
"--mount", "type=bind,src=${env:HOME}/.ssh,dst=/home/developer/.ssh", | ||
"-p", "2222:22", | ||
"--name", "vscode_dev_container", | ||
"-e", "DCGM_BUILD_INSIDE_DOCKER=1", | ||
"-e", "NVIDIA_DRIVER_CAPABILITIES=compute,utility", | ||
"-e", "NVIDIA_VISIBLE_DEVICES=ALL", | ||
"--cap-add=SYS_ADMIN", | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
"--gpus=all" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,3 +92,7 @@ validate-modules: | |
@echo "- Checking for any unused/missing packages in go.mod..." | ||
go mod tidy | ||
@git diff --exit-code -- go.sum go.mod | ||
|
||
.PHONY: tools | ||
tools: ## Install required tools and utilities | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] |