1+ #! /bin/bash
12# Original script from https://github.com/ptheywood/cuda-cmake-github-actions
23
34CUDA_PACKAGES_IN=(
@@ -17,7 +18,7 @@ function version_ge() {
1718# returns 0 (true) if a > b
1819function version_gt() {
1920 [ " $# " != " 2" ] && echo " ${FUNCNAME[0]} requires exactly 2 arguments." && exit 1
20- [ " $1 " = " $2 " ] && return 1 || version_ge $1 $2
21+ [ " $1 " = " $2 " ] && return 1 || version_ge " $1 " " $2 "
2122}
2223# returns 0 (true) if a <= b
2324function version_le() {
@@ -27,13 +28,13 @@ function version_le() {
2728# returns 0 (true) if a < b
2829function version_lt() {
2930 [ " $# " != " 2" ] && echo " ${FUNCNAME[0]} requires exactly 2 arguments." && exit 1
30- [ " $1 " = " $2 " ] && return 1 || version_le $1 $2
31+ [ " $1 " = " $2 " ] && return 1 || version_le " $1 " " $2 "
3132}
3233
3334# # Select CUDA version
3435
3536# Get the cuda version from the environment as $cuda.
36- CUDA_VERSION_MAJOR_MINOR=${cuda}
37+ CUDA_VERSION_MAJOR_MINOR=${cuda:= 12.8 }
3738
3839# Split the version.
3940# We (might/probably) don't know PATCH at this point - it depends which version gets installed.
@@ -60,7 +61,7 @@ if [ -z "${CUDA_MINOR}" ] ; then
6061 exit 1
6162fi
6263# If we don't know the Ubuntu version, error.
63- if [ -z ${UBUNTU_VERSION} ]; then
64+ if [ -z " ${UBUNTU_VERSION} " ]; then
6465 echo " Error: Unknown Ubuntu version. Aborting."
6566 exit 1
6667fi
@@ -112,15 +113,15 @@ echo "KEYRING_PACKAGE_URL ${KEYRING_PACKAGE_URL}"
112113
113114# Detect if the script is being run as root, storing true/false in is_root.
114115is_root=false
115- if (( $ EUID == 0 )) ; then
116+ if (( EUID == 0 )) ; then
116117 is_root=true
117118fi
118119# Find if sudo is available
119120has_sudo=false
120121if command -v sudo & > /dev/null ; then
121122 has_sudo=true
122123fi
123- # Decide if we can proceed or not (root or sudo is required) and if so store whether sudo should be used or not.
124+ # Decide if we can proceed or not (root or sudo is required) and if so store whether sudo should be used or not.
124125if [ " $is_root " = false ] && [ " $has_sudo " = false ]; then
125126 echo " Root or sudo is required. Aborting."
126127 exit 1
@@ -136,16 +137,15 @@ $USE_SUDO apt-get update
136137
137138# # Install
138139echo " Adding CUDA Repository"
139- wget ${PIN_URL}
140- $USE_SUDO mv ${PIN_FILENAME} /etc/apt/preferences.d/cuda-repository-pin-600
141- wget ${KEYRING_PACKAGE_URL} && ${USE_SUDO} dpkg -i ${KERYRING_PACKAGE_FILENAME} && rm ${KERYRING_PACKAGE_FILENAME}
140+ wget " ${PIN_URL} "
141+ $USE_SUDO mv " ${PIN_FILENAME} " /etc/apt/preferences.d/cuda-repository-pin-600
142+ wget " ${KEYRING_PACKAGE_URL} " && ${USE_SUDO} dpkg -i ${KERYRING_PACKAGE_FILENAME} && rm ${KERYRING_PACKAGE_FILENAME}
142143$USE_SUDO add-apt-repository " deb ${REPO_URL} /"
143144$USE_SUDO apt-get update
144145
145146echo " Installing CUDA packages ${CUDA_PACKAGES} "
146- $USE_SUDO apt-get -y install ${CUDA_PACKAGES}
147147
148- if [[ $? -ne 0 ]] ; then
148+ if ! $USE_SUDO apt-get -y install " ${CUDA_PACKAGES} " ; then
149149 echo " CUDA Installation Error."
150150 exit 1
151151fi
0 commit comments