Skip to content

Commit

Permalink
Merge pull request #264 from NVIDIA/added-devcontainer
Browse files Browse the repository at this point in the history
Added devcontainer
  • Loading branch information
nvvfedorov committed Feb 26, 2024
2 parents 757e7e7 + 542bf34 commit 9547688
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .devcontainer/Dockerfile
@@ -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
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
@@ -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"
]
}
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -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/golangci-lint@v1.55.2

0 comments on commit 9547688

Please sign in to comment.