From 9b28bde7154462de7152bad332eeccd5f3b61af6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 14:45:54 +0000 Subject: [PATCH 1/3] Initial plan From 71a796880d8f7c910a596237a6497d1e89934f06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 15:02:03 +0000 Subject: [PATCH 2/3] feat: add nvidia.com-cuda feature Co-authored-by: sebst <592313+sebst@users.noreply.github.com> --- .github/workflows/test.yaml | 2 + src/nvidia.com-cuda/devcontainer-feature.json | 25 +++++ src/nvidia.com-cuda/install.sh | 92 +++++++++++++++++++ test/nvidia.com-cuda/test.sh | 17 ++++ 4 files changed, 136 insertions(+) create mode 100644 src/nvidia.com-cuda/devcontainer-feature.json create mode 100755 src/nvidia.com-cuda/install.sh create mode 100755 test/nvidia.com-cuda/test.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d1fba94..8cb03b2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,6 +25,7 @@ jobs: - feature-installer - jj-vcs.dev - nixos.org + - nvidia.com-cuda - opencode.ai - pkgx.sh - smallstep.com @@ -63,6 +64,7 @@ jobs: - feature-installer - jj-vcs.dev - nixos.org + - nvidia.com-cuda - opencode.ai - pkgx.sh - smallstep.com diff --git a/src/nvidia.com-cuda/devcontainer-feature.json b/src/nvidia.com-cuda/devcontainer-feature.json new file mode 100644 index 0000000..89283e0 --- /dev/null +++ b/src/nvidia.com-cuda/devcontainer-feature.json @@ -0,0 +1,25 @@ +{ + "name": "nvidia.com/cuda", + "id": "nvidia.com-cuda", + "version": "1.0.0", + "description": "Install NVIDIA CUDA Toolkit", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/nvidia.com-cuda", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest", + "12.6", + "12.5", + "12.4", + "12.3", + "12.2", + "12.1", + "12.0", + "11.8" + ], + "description": "Version of CUDA Toolkit to install (e.g. \"latest\", \"12.6\")." + } + } +} diff --git a/src/nvidia.com-cuda/install.sh b/src/nvidia.com-cuda/install.sh new file mode 100755 index 0000000..4bf5a80 --- /dev/null +++ b/src/nvidia.com-cuda/install.sh @@ -0,0 +1,92 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name='cuda' +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} +apt_get_checkinstall() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@" + fi +} +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +get_distro_codename() { + local distro + local version_id + distro="$(. /etc/os-release && echo "$ID")" + version_id="$(. /etc/os-release && echo "$VERSION_ID" | tr -d '.')" + echo "${distro}${version_id}" +} +get_cuda_arch() { + local arch + arch="$(uname -m)" + case "$arch" in + x86_64) echo 'x86_64' ;; + aarch64) echo 'sbsa' ;; + *) + printf >&2 '=== [ERROR] Unsupported architecture: %s\n' "$arch" + exit 1 + ;; + esac +} +utils_check_version() { + local version=$1 + if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+)$ ]]; then + printf >&2 '=== [ERROR] Option "version" (value: "%s") is not "latest" or a valid CUDA version format "X.Y" (e.g. "12.6")!\n' \ + "$version" + exit 1 + fi +} +install() { + utils_check_version "$VERSION" + apt_get_checkinstall wget ca-certificates + local distro + local arch + local keyring_url + local keyring_deb + local package_name + distro="$(get_distro_codename)" + arch="$(get_cuda_arch)" + # cuda-keyring version: update when NVIDIA publishes a newer keyring package + # See https://developer.download.nvidia.com/compute/cuda/repos/ for available versions + readonly cuda_keyring_version='1.1-1' + keyring_url="https://developer.download.nvidia.com/compute/cuda/repos/${distro}/${arch}/cuda-keyring_${cuda_keyring_version}_all.deb" + keyring_deb="/tmp/cuda-keyring_${cuda_keyring_version}_all.deb" + echo "Downloading CUDA keyring from: ${keyring_url}" + wget -q -O "${keyring_deb}" "${keyring_url}" + dpkg -i "${keyring_deb}" + rm -f "${keyring_deb}" + apt-get update -y + if [ "${VERSION}" = 'latest' ]; then + package_name='cuda-toolkit' + else + local version_normalized + version_normalized="$(echo "${VERSION}" | tr '.' '-')" + package_name="cuda-toolkit-${version_normalized}" + fi + echo "Installing package: ${package_name}" + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests \ + --option 'Debug::pkgProblemResolver=true' \ + --option 'Debug::pkgAcquire::Worker=1' \ + "${package_name}" + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing ${name}..." +install "$@" +echo "(*) Done!" diff --git a/test/nvidia.com-cuda/test.sh b/test/nvidia.com-cuda/test.sh new file mode 100755 index 0000000..8154393 --- /dev/null +++ b/test/nvidia.com-cuda/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check