forked from mozilla/sccache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install CUDA toolkit so we test nvcc in workflows/ci.yml
- Loading branch information
Showing
5 changed files
with
177 additions
and
2 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,16 @@ | ||
name: nvcc-toolchain | ||
inputs: | ||
cuda-version: | ||
description: CUDA Toolkit version | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- if: runner.os == 'Linux' | ||
shell: bash | ||
run: .github/actions/nvcc-toolchain/install-cuda.sh ${{ inputs.cuda-version }} | ||
|
||
- if: runner.os == 'Windows' | ||
shell: powershell | ||
run: .\.github\actions\nvcc-toolchain\install-cuda.ps1 -cudaVersion ${{ inputs.cuda-version }} |
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,47 @@ | ||
Param( | ||
[Parameter(Mandatory=$false)] | ||
[string] | ||
$cudaVersion="12.6.0" | ||
) | ||
|
||
# Use System.Version to tokenize version | ||
$version = [Version]$cudaVersion | ||
|
||
$major = $version.Major | ||
$minor = $version.Minor | ||
$build = $version.Build | ||
|
||
# Minimum build is 0, not -1 as default in case "12.5" is passed | ||
if ($build -lt 0) { | ||
$build = 0 | ||
} | ||
|
||
# mmb == major minor build | ||
$mmbVersionTag = "${major}.${minor}.${build}" | ||
# mm = major minor | ||
$mmVersionTag = "${major}.${minor}" | ||
|
||
$cudaMajorUri = @{ | ||
"11" = "${mmbVersionTag}/network_installers/cuda_${mmbVersionTag}_win10_network.exe" | ||
"12" = "${mmbVersionTag}/network_installers/cuda_${mmbVersionTag}_windows_network.exe" | ||
}["$major"] | ||
|
||
$cudaVersionUrl = "https://developer.download.nvidia.com/compute/cuda/$cudaMajorUri" | ||
$cudaComponents = | ||
"nvcc_$mmVersionTag", | ||
"curand_$mmVersionTag", | ||
"curand_dev_$mmVersionTag", | ||
"cudart_$mmVersionTag", | ||
"cupti_$mmVersionTag", | ||
"nvrtc_$mmVersionTag", | ||
"nvrtc_dev_$mmVersionTag", | ||
"nvml_dev_$mmVersionTag", | ||
"nvtx_$mmVersionTag" | ||
|
||
Invoke-WebRequest -Uri "$cudaVersionUrl" -OutFile "./cuda_network.exe" -UseBasicParsing | ||
Start-Process -Wait -PassThru -FilePath .\cuda_network.exe -ArgumentList "-s $cudaComponents" | ||
|
||
$ENV:PATH="$ENV:PATH;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$mmVersionTag\bin" | ||
$ENV:CUDA_PATH="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$mmVersionTag" | ||
|
||
Remove-Item .\cuda_network.exe |
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,88 @@ | ||
#! /usr/bin/env bash | ||
set -eux | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
get_cuda_deb() { | ||
local deb="$( \ | ||
wget --no-hsts -q -O- "${1}/Packages" \ | ||
| grep -P "^Filename: \./${2}(.*)\.deb$" \ | ||
| sort -Vr | head -n1 | cut -d' ' -f2 \ | ||
)"; | ||
if [ -z "$deb" ]; then | ||
echo "Error: No matching .deb found for '${1}' and '${2}'" >&2 | ||
return 1 | ||
fi | ||
wget --no-hsts -q -O "/tmp/${deb#./}" "${1}/${deb#./}"; | ||
echo -n "/tmp/${deb#./}"; | ||
} | ||
|
||
VERSION="$1"; | ||
|
||
NVARCH="$(uname -p)"; | ||
|
||
if test "$NVARCH" = aarch64; then | ||
NVARCH="sbsa"; | ||
fi | ||
|
||
OSNAME="$( | ||
. /etc/os-release; | ||
major="$(cut -d'.' -f1 <<< "${VERSION_ID}")"; | ||
minor="$(cut -d'.' -f2 <<< "${VERSION_ID}")"; | ||
echo "$ID$((major - (major % 2)))${minor}"; | ||
)"; | ||
|
||
CUDA_HOME="/usr/local/cuda"; | ||
|
||
cuda_repo_base="https://developer.download.nvidia.com/compute/cuda/repos"; | ||
cuda_repo="${cuda_repo_base}/${OSNAME}/${NVARCH}"; | ||
|
||
cuda_ver="$VERSION"; | ||
cuda_ver="$(grep -Po '^[0-9]+\.[0-9]+' <<< "${cuda_ver}")"; | ||
cuda_ver="${cuda_ver/./-}"; | ||
|
||
if ! dpkg -s cuda-keyring; then | ||
sudo apt-get install -y --no-install-recommends \ | ||
"$(get_cuda_deb "${cuda_repo}" cuda-keyring)" \ | ||
; | ||
fi | ||
|
||
PKGS=(); | ||
PKGS+=("cuda-nvcc-${cuda_ver}"); | ||
|
||
sudo apt-get update; | ||
sudo apt-get install -y --no-install-recommends "${PKGS[@]}"; | ||
|
||
if ! test -L "${CUDA_HOME}"; then | ||
# Create /usr/local/cuda symlink | ||
sudo ln -s "${CUDA_HOME}-${cuda_ver}" "${CUDA_HOME}"; | ||
fi | ||
|
||
if test -z "${CUDA_VERSION:-}"; then | ||
if test -f "${CUDA_HOME}/include/cuda.h"; then | ||
cuda_ver="$(grep "#define CUDA_VERSION" "${CUDA_HOME}/include/cuda.h" | cut -d' ' -f3)"; | ||
CUDA_VERSION_MAJOR="$((cuda_ver / 1000))"; | ||
CUDA_VERSION_MINOR="$((cuda_ver / 10 % 100))"; | ||
CUDA_VERSION_PATCH="$((cuda_ver % 10))"; | ||
CUDA_VERSION="$CUDA_VERSION_MAJOR.$CUDA_VERSION_MINOR.$CUDA_VERSION_PATCH"; | ||
else | ||
CUDA_VERSION_MAJOR="$(cut -d'.' -f1 <<< "${VERSION}")"; | ||
CUDA_VERSION_MINOR="$(cut -d'.' -f2 <<< "${VERSION}")"; | ||
CUDA_VERSION_PATCH="$(cut -d'.' -f3 <<< "${VERSION}")"; | ||
CUDA_VERSION_PATCH="${CUDA_VERSION_PATCH:-0}" | ||
CUDA_VERSION="$CUDA_VERSION_MAJOR.$CUDA_VERSION_MINOR.$CUDA_VERSION_PATCH"; | ||
fi | ||
fi | ||
|
||
cat <<EOF | tee -a "$GITHUB_ENV" | ||
NVARCH="$NVARCH" | ||
CUDA_HOME="$CUDA_HOME" | ||
CUDA_PATH="$CUDA_HOME" | ||
CUDA_VERSION="$CUDA_VERSION" | ||
CUDA_VERSION_MAJOR="$CUDA_VERSION_MAJOR" | ||
CUDA_VERSION_MINOR="$CUDA_VERSION_MINOR" | ||
CUDA_VERSION_PATCH="$CUDA_VERSION_PATCH" | ||
PATH="$CUDA_HOME/bin:${PATH}" | ||
EOF | ||
|
||
rm /tmp/*.deb |
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
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