Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new NVIDIA CUDA feature #80

Merged
merged 38 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
caa4520
Add new Nvidia feature
jungaretti Aug 4, 2022
2e115a9
Remove random empty files
jungaretti Aug 4, 2022
82cf979
Update comments
jungaretti Aug 4, 2022
25a7dc7
Merge branch 'main' into jungaretti/nvidia-feature
joshspicer Aug 5, 2022
0d6fe41
Rename feature to nvidia-cuda
jungaretti Aug 8, 2022
f0dee9d
Add feature to tests
jungaretti Aug 8, 2022
c729aef
Add version
jungaretti Aug 8, 2022
ce560c7
Merge branch 'main' of https://github.com/devcontainers/features into…
jungaretti Aug 8, 2022
f329740
Move test to match new name
jungaretti Aug 8, 2022
ccc5282
Add final output message
jungaretti Aug 8, 2022
2a7d079
Fix capitalization of NVIDIA
jungaretti Aug 8, 2022
9aef242
Remove option for base CUDA
jungaretti Aug 11, 2022
67309af
Use camelCase
jungaretti Aug 11, 2022
8a44491
Check for required packages
jungaretti Aug 15, 2022
30a4aa6
Use os-release instead of lsb_release
jungaretti Aug 15, 2022
90afb4a
Clean up keyring variables
jungaretti Aug 15, 2022
ba1da2a
Collapse keyring lines
jungaretti Aug 15, 2022
62bceba
Always install CUDA libraries
jungaretti Aug 15, 2022
96423df
Add option to install NVTX
jungaretti Aug 15, 2022
caf879a
Merge branch 'main' of https://github.com/devcontainers/features into…
jungaretti Aug 16, 2022
3ab6580
Always use ubuntu2004 repo
jungaretti Aug 16, 2022
c1a051d
Use test instead of brackets
jungaretti Aug 17, 2022
8a6d52b
Add default values to feature
jungaretti Aug 17, 2022
f246115
Add version options for CUDA and cuDNN
jungaretti Aug 17, 2022
52da1e5
Rename CUDA version option
jungaretti Aug 17, 2022
d3e145b
Add scenario to test specific CUDA/cuDNN version
jungaretti Aug 17, 2022
287aa65
Rename cuDNN scenario
jungaretti Aug 17, 2022
ef45b35
Fix typo in test scenario
jungaretti Aug 17, 2022
e6b9356
Update variable casing
jungaretti Aug 17, 2022
11d217a
Add more helpful error messages
jungaretti Aug 18, 2022
a89dac0
Remove default values from script
jungaretti Aug 19, 2022
d17069e
Use enum for version option
jungaretti Aug 20, 2022
9e6255c
Polish new scenarios
jungaretti Aug 20, 2022
c7a61d3
Remove apt_get_update_if_needed and check_packages
jungaretti Aug 20, 2022
f4b62d2
Merge branch 'main' of https://github.com/devcontainers/features into…
jungaretti Aug 20, 2022
ae65577
Add more versions
jungaretti Aug 20, 2022
7d57487
Improve error messages
jungaretti Aug 20, 2022
fe2bada
Comments and feature description
jungaretti Aug 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
"java",
"kubectl-helm-minikube",
"node",
"nvidia-cuda",
"oryx",
"php",
"powershell",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
java: ./**/java/**
kubectl-helm-minikube: ./**/kubectl-helm-minikube/**
node: ./**/node/**
nvidia-cuda: ./**/nvidia-cuda/**
oryx: ./**/oryx/**
php: ./**/php/**
powershell: ./**/powershell/**
Expand Down
28 changes: 28 additions & 0 deletions src/nvidia-cuda/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"id": "nvidia-cuda",
"name": "NVIDIA CUDA",
"description": "Installs NVIDIA CUDA libraries.",
"version": "1.0.0",
"options": {
"installCudnn": {
"type": "boolean",
"default": false,
"description": "Install CUDA Deep Neural Network (cuDNN) library"
},
"installNvtx": {
"type": "boolean",
"default": false,
"description": "Install NVIDIA Tools Extension (NVTX)"
},
"version": {
"type": "string",
"default": "latest",
"description": "Version of CUDA to install, formatted as MAJOR.MINOR (for example, 11.7)"
},
"cudnnVersion": {
"type": "string",
"default": "latest",
"description": "Full version of cuDNN to install (for example, 8.5.0.96-1)"
}
}
}
75 changes: 75 additions & 0 deletions src/nvidia-cuda/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash

set -e

INSTALL_CUDNN=${INSTALLCUDNN:-"false"}
INSTALL_NVTX=${INSTALLNVTX:-"false"}
CUDA_VERSION=${VERSION:-"latest"}
CUDNN_VERSION=${CUDNNVERSION:-"latest"}

# NVIDIA's package names include this information
LATEST_CUDA_VERSION="11.7"
LATEST_CUDNN_VERSION="8.5.0.96-1"
jungaretti marked this conversation as resolved.
Show resolved Hide resolved
if [ "$CUDA_VERSION" = "latest" ]; then CUDA_VERSION="$LATEST_CUDA_VERSION"; fi
if [ "$CUDNN_VERSION" = "latest" ]; then CUDNN_VERSION="$LATEST_CUDNN_VERSION"; fi

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

jungaretti marked this conversation as resolved.
Show resolved Hide resolved
# Function to run apt-get if needed
apt_get_update_if_needed() {
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
jungaretti marked this conversation as resolved.
Show resolved Hide resolved
else
echo "Skipping apt-get update."
fi
}

# Prints a more helpful error message when installation fails
apt_try_install() {
apt-get install -yq "$1" || {
local exit_code=$?
echo "Failed to install $1"
echo "See $NVIDIA_REPO_URL for all available packages and versions"
return $exit_code
}
}

# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt-get -y install --no-install-recommends "$@"
fi
}

check_packages wget ca-certificates

# Add NVIDIA's package repository to apt so that we can download packages
# Always use the ubuntu2004 repo because the other repos (e.g., debian11) are missing packages
NVIDIA_REPO_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64"
KEYRING_PACKAGE="cuda-keyring_1.0-1_all.deb"
KEYRING_PACKAGE_URL="$NVIDIA_REPO_URL/$KEYRING_PACKAGE"
KEYRING_PACKAGE_PATH="$(mktemp -d)"
KEYRING_PACKAGE_FILE="$KEYRING_PACKAGE_PATH/$KEYRING_PACKAGE"
wget -O "$KEYRING_PACKAGE_FILE" "$KEYRING_PACKAGE_URL"
apt-get install -yq "$KEYRING_PACKAGE_FILE"
apt-get update -yq

echo "Installing CUDA libraries..."
apt_try_install "cuda-libraries-${CUDA_VERSION/./-}"

if [ "$INSTALL_CUDNN" = "true" ]; then
echo "Installing cuDNN libraries..."
apt_try_install "libcudnn8=${CUDNN_VERSION}+cuda${CUDA_VERSION}"
fi

if [ "$INSTALL_NVTX" = "true" ]; then
echo "Installing NVTX..."
apt_try_install "cuda-nvtx-${CUDA_VERSION/./-}"
fi

echo "Done!"
12 changes: 12 additions & 0 deletions test-scenarios/install_cudnn_nvxt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

check "libcudnn.so.8" test 1 -eq "$(find /usr -name 'libcudnn.so.8.3.2' | wc -l)"
check "nvtx" test -e '/usr/local/cuda-11.5/targets/x86_64-linux/include/nvtx3'

# Report result
reportResults
11 changes: 11 additions & 0 deletions test-scenarios/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,16 @@
"version": "3"
}
}
},
"install_cudnn_nvxt": {
"image": "debian",
"features": {
"nvidia-cuda": {
"installCudnn": true,
"installNvtx": true,
"version": "11.5",
"cudnnVersion": "8.3.2.44-1"
}
}
}
}
18 changes: 18 additions & 0 deletions test/nvidia-cuda/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# Definition specific tests
check "libcudart.so.11.0" test 1 -eq "$(find /usr -name 'libcudart.so.11.0' | wc -l)"
check "libcublas.so.11" test 1 -eq "$(find /usr -name 'libcublas.so.11' | wc -l)"
check "libcublasLt.so.11" test 1 -eq "$(find /usr -name 'libcublasLt.so.11' | wc -l)"
check "libcufft.so.10" test 1 -eq "$(find /usr -name 'libcufft.so.10' | wc -l)"
check "libcurand.so.10" test 1 -eq "$(find /usr -name 'libcurand.so.10' | wc -l)"
check "libcusolver.so.11" test 1 -eq "$(find /usr -name 'libcusolver.so.11' | wc -l)"
check "libcusparse.so.11" test 1 -eq "$(find /usr -name 'libcusparse.so.11' | wc -l)"

# Report result
reportResults