diff --git a/EESSI-install-software.sh b/EESSI-install-software.sh index a38a1c047a..04e5e0a401 100755 --- a/EESSI-install-software.sh +++ b/EESSI-install-software.sh @@ -17,11 +17,6 @@ display_help() { echo " --skip-cuda-install - disable installing a full CUDA SDK in the host_injections prefix (e.g. in CI)" } -# Function to check if a command exists -function command_exists() { - command -v "$1" >/dev/null 2>&1 -} - function copy_build_log() { # copy specified build log to specified directory, with some context added build_log=${1} @@ -302,16 +297,7 @@ fi # Install NVIDIA drivers in host_injections (if they exist) if command_exists "nvidia-smi"; then export LD_LIBRARY_PATH="/.singularity.d/libs:${LD_LIBRARY_PATH}" - nvidia-smi --version - ec=$? - if [ ${ec} -eq 0 ]; then - echo "Command 'nvidia-smi' found. Installing NVIDIA drivers for use in prefix shell..." - ${EESSI_PREFIX}/scripts/gpu_support/nvidia/link_nvidia_host_libraries.sh - else - echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully." - echo "This script now assumes this is NOT a GPU node." - echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error." - fi + check_nvidia-smi_installation fi if [ ! -z "${shared_fs_path}" ]; then diff --git a/bot/build.sh b/bot/build.sh index 2bba0cba55..7875e70f09 100755 --- a/bot/build.sh +++ b/bot/build.sh @@ -264,18 +264,8 @@ BUILD_STEP_ARGS+=("--storage" "${STORAGE}") if command_exists "nvidia-smi"; then # Accept that this may fail set +e - nvidia-smi --version - ec=$? + check_nvidia-smi_installation set -e - if [ ${ec} -eq 0 ]; then - echo "Command 'nvidia-smi' found, using available GPU" - BUILD_STEP_ARGS+=("--nvidia" "all") - else - echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully." - echo "This script now assumes this is NOT a GPU node." - echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error." - BUILD_STEP_ARGS+=("--nvidia" "install") - fi else echo "No 'nvidia-smi' found, no available GPU but allowing overriding this check" BUILD_STEP_ARGS+=("--nvidia" "install") diff --git a/bot/test.sh b/bot/test.sh index b615be0020..e931521499 100755 --- a/bot/test.sh +++ b/bot/test.sh @@ -221,17 +221,8 @@ TEST_STEP_ARGS+=("--extra-bind-paths" "/sys/fs/cgroup:/hostsys/fs/cgroup:ro") if command_exists "nvidia-smi"; then # Accept that this may fail set +e - nvidia-smi --version - ec=$? + check_nvidia-smi_installation set -e - if [ ${ec} -eq 0 ]; then - echo "Command 'nvidia-smi' found, using available GPU" - TEST_STEP_ARGS+=("--nvidia" "run") - else - echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully." - echo "This script now assumes this is NOT a GPU node." - echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error." - fi fi # prepare arguments to test_suite.sh (specific to test step) diff --git a/scripts/utils.sh b/scripts/utils.sh index 962decd20e..426f622253 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -147,3 +147,16 @@ function get_ipv4_address { echo "${hipv4}" return 0 } + +function check_nvidia-smi_installation { + nvidia-smi --version + ec=$? + if [ ${ec} -eq 0 ]; then + echo "Command 'nvidia-smi' found. Installing NVIDIA drivers for use in prefix shell..." + ${EESSI_PREFIX}/scripts/gpu_support/nvidia/link_nvidia_host_libraries.sh + else + echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully." + echo "This script now assumes this is NOT a GPU node." + echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error." + fi +}