Skip to content

Commit 6bb7156

Browse files
committed
Create for utils function nvidia-smi check
Signed-off-by: laraPPr <[email protected]>
1 parent a676158 commit 6bb7156

File tree

4 files changed

+16
-36
lines changed

4 files changed

+16
-36
lines changed

EESSI-install-software.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ display_help() {
1717
echo " --skip-cuda-install - disable installing a full CUDA SDK in the host_injections prefix (e.g. in CI)"
1818
}
1919

20-
# Function to check if a command exists
21-
function command_exists() {
22-
command -v "$1" >/dev/null 2>&1
23-
}
24-
2520
function copy_build_log() {
2621
# copy specified build log to specified directory, with some context added
2722
build_log=${1}
@@ -307,16 +302,7 @@ fi
307302
# Install NVIDIA drivers in host_injections (if they exist)
308303
if command_exists "nvidia-smi"; then
309304
export LD_LIBRARY_PATH="/.singularity.d/libs:${LD_LIBRARY_PATH}"
310-
nvidia-smi --version
311-
ec=$?
312-
if [ ${ec} -eq 0 ]; then
313-
echo "Command 'nvidia-smi' found. Installing NVIDIA drivers for use in prefix shell..."
314-
${EESSI_PREFIX}/scripts/gpu_support/nvidia/link_nvidia_host_libraries.sh
315-
else
316-
echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully."
317-
echo "This script now assumes this is NOT a GPU node."
318-
echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error."
319-
fi
305+
check_nvidia-smi_installation
320306
fi
321307

322308
if [ ! -z "${shared_fs_path}" ]; then

bot/build.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,8 @@ BUILD_STEP_ARGS+=("--storage" "${STORAGE}")
264264
if command_exists "nvidia-smi"; then
265265
# Accept that this may fail
266266
set +e
267-
nvidia-smi --version
268-
ec=$?
267+
check_nvidia-smi_installation
269268
set -e
270-
if [ ${ec} -eq 0 ]; then
271-
echo "Command 'nvidia-smi' found, using available GPU"
272-
BUILD_STEP_ARGS+=("--nvidia" "all")
273-
else
274-
echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully."
275-
echo "This script now assumes this is NOT a GPU node."
276-
echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error."
277-
BUILD_STEP_ARGS+=("--nvidia" "install")
278-
fi
279269
else
280270
echo "No 'nvidia-smi' found, no available GPU but allowing overriding this check"
281271
BUILD_STEP_ARGS+=("--nvidia" "install")

bot/test.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,8 @@ TEST_STEP_ARGS+=("--extra-bind-paths" "/sys/fs/cgroup:/hostsys/fs/cgroup:ro")
222222
if command_exists "nvidia-smi"; then
223223
# Accept that this may fail
224224
set +e
225-
nvidia-smi --version
226-
ec=$?
225+
check_nvidia-smi_installation
227226
set -e
228-
if [ ${ec} -eq 0 ]; then
229-
echo "Command 'nvidia-smi' found, using available GPU"
230-
TEST_STEP_ARGS+=("--nvidia" "run")
231-
else
232-
echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully."
233-
echo "This script now assumes this is NOT a GPU node."
234-
echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error."
235-
fi
236227
fi
237228

238229
# prepare arguments to test_suite.sh (specific to test step)

scripts/utils.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,16 @@ function get_ipv4_address {
147147
echo "${hipv4}"
148148
return 0
149149
}
150+
151+
function check_nvidia-smi_installation {
152+
nvidia-smi --version
153+
ec=$?
154+
if [ ${ec} -eq 0 ]; then
155+
echo "Command 'nvidia-smi' found. Installing NVIDIA drivers for use in prefix shell..."
156+
${EESSI_PREFIX}/scripts/gpu_support/nvidia/link_nvidia_host_libraries.sh
157+
else
158+
echo "Warning: command 'nvidia-smi' found, but 'nvidia-smi --version' did not run succesfully."
159+
echo "This script now assumes this is NOT a GPU node."
160+
echo "If, and only if, the current node actually does contain Nvidia GPUs, this should be considered an error."
161+
fi
162+
}

0 commit comments

Comments
 (0)