Skip to content

Commit 5d9e70c

Browse files
committed
Limit accelerator installations to CPU only
1 parent 785c15f commit 5d9e70c

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

EESSI-extend-easybuild.eb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ elseif (os.getenv("EESSI_SITE_INSTALL") ~= nil) then
104104
LmodError("You cannot use EESSI_SITE_INSTALL in combination with any other EESSI_*_INSTALL environment variables")
105105
end
106106
easybuild_installpath = os.getenv("EESSI_SITE_SOFTWARE_PATH")
107+
eessi_accelerator_target = os.getenv("EESSI_ACCELERATOR_TARGET")
108+
if (eessi_accelerator_target ~= nil) then
109+
cuda_compute_capability = string.match(eessi_accelerator_target, "^nvidia/cc([0-9][0-9])$")
110+
if (cuda_compute_capability ~= nil) then
111+
easybuild_installpath = pathJoin(easybuild_installpath, 'accel', eessi_accelerator_target)
112+
easybuild_cuda_compute_capabilities = cuda_compute_capability:sub(1, 1) .. "." .. cuda_compute_capability:sub(2, 2)
113+
else
114+
LmodError("Incorrect value for $EESSI_ACCELERATOR_TARGET: " .. eessi_accelerator_target)
115+
end
116+
end
107117
else
108118
-- Deal with user and project installs
109119
project_install = os.getenv("EESSI_PROJECT_INSTALL")

eb_hooks.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,37 @@ def pre_fetch_hook(self, *args, **kwargs):
421421
if cpu_target == CPU_TARGET_ZEN4:
422422
pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs)
423423

424+
# Always check the software installation path
425+
pre_fetch_hook_check_installation_path(self, *args, **kwargs)
426+
427+
428+
# Check the installation path so we verify that accelerator software always gets installed into the correct location
429+
def pre_fetch_hook_check_installation_path(self, *args, **kwargs):
430+
# When we know the CUDA status, we will need to verify the installation path
431+
# if we are doing an EESSI or host_injections installation
432+
accelerator_deps = ['CUDA']
433+
strict_eessi_installation = (
434+
bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir)) or
435+
self.installdir.startswith(HOST_INJECTIONS_LOCATION))
436+
if strict_eessi_installation:
437+
dependency_names = self.cfg.dependency_names()
438+
if self.cfg.name in accelerator_deps or any(dep in dependency_names for dep in accelerator_deps):
439+
# Make sure the path is an accelerator location
440+
if "/accel/" not in self.installdir:
441+
raise EasyBuildError(
442+
f"It seems you are trying to install an accelerator package {self.cfg.name} into a "
443+
f"non-accelerator location {self.installdir}. You need to reconfigure your installation to target "
444+
"the correct location."
445+
)
446+
else:
447+
# If we don't have an accelerator dependency then we should be in a CPU installation path
448+
if "/accel/" in self.installdir:
449+
raise EasyBuildError(
450+
f"It seems you are trying to install a CPU-only package {self.cfg.name} into accelerator location "
451+
f"{self.installdir}. If this is a dependency of the package you are really interested in you will "
452+
"need to first install the CPU-only dependencies of that package."
453+
)
454+
424455

425456
def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs):
426457
"""Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4.

init/bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ if [ $? -eq 0 ]; then
3232
if [ ! -z ${EESSI_MODULEPATH_ACCEL} ]; then
3333
show_msg "Prepending $EESSI_MODULEPATH_ACCEL to \$MODULEPATH..."
3434
module use $EESSI_MODULEPATH_ACCEL
35+
show_msg "Prepending $EESSI_SITE_MODULEPATH_ACCEL to \$MODULEPATH..."
36+
module use $EESSI_SITE_MODULEPATH_ACCEL
3537
fi
3638

3739
#show_msg ""

init/eessi_environment_variables

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ if [ -d $EESSI_PREFIX ]; then
112112
elif [ -d $EESSI_SOFTWARE_PATH ]; then
113113
export EESSI_SITE_SOFTWARE_PATH=${EESSI_SOFTWARE_PATH/versions/host_injections}
114114
show_msg "Using ${EESSI_SITE_SOFTWARE_PATH} as the site extension directory for installations."
115+
export EESSI_SITE_ACCEL_SOFTWARE_PATH=${EESSI_ACCEL_SOFTWARE_PATH/versions/host_injections}
116+
show_msg "Using ${EESSI_SITE_ACCEL_SOFTWARE_PATH} as the site extension directory for accelerated installations."
115117
# Allow for use of alternative module tree shipped with EESSI
116118
if [ -z ${EESSI_MODULE_SUBDIR+x} ]; then
117119
# EESSI_MODULE_SUBDIR not set
@@ -140,8 +142,11 @@ if [ -d $EESSI_PREFIX ]; then
140142
if [ -d ${EESSI_ACCEL_SOFTWARE_PATH}/${EESSI_ACCEL_SUBDIR}/${EESSI_MODULE_SUBDIR} ]; then
141143
export EESSI_MODULEPATH_ACCEL=${EESSI_ACCEL_SOFTWARE_PATH}/${EESSI_ACCEL_SUBDIR}/${EESSI_MODULE_SUBDIR}
142144
show_msg "Using ${EESSI_MODULEPATH_ACCEL} as additional directory (for accelerators) to be added to MODULEPATH."
145+
export EESSI_SITE_MODULEPATH_ACCEL=${EESSI_SITE_ACCEL_SOFTWARE_PATH}/${EESSI_ACCEL_SUBDIR}/${EESSI_MODULE_SUBDIR}
146+
show_msg "Using ${EESSI_SITE_MODULEPATH_ACCEL} as additional site extension directory (for accelerators) to be added to MODULEPATH."
143147
fi
144148

149+
145150
# Fix wrong path for RHEL >=8 libcurl
146151
# This is required here because we ship curl in our compat layer. If we only provided
147152
# curl as a module file we could instead do this via a `modluafooter` in an EasyBuild

init/modules/EESSI/2023.06.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ if not (archdetect_accel == nil or archdetect_accel == '') then
144144
setenv("EESSI_MODULEPATH_ACCEL", eessi_module_path_accel)
145145
prepend_path("MODULEPATH", eessi_module_path_accel)
146146
eessiDebug("Using acclerator modules at: " .. eessi_module_path_accel)
147+
-- do the same for site installs
148+
eessi_module_path_site_accel = string.gsub(eessi_module_path_accel, "versions", "host_injections")
149+
setenv("EESSI_SITE_MODULEPATH_ACCEL", eessi_module_path_site_accel)
150+
prepend_path("MODULEPATH", eessi_module_path_site_accel)
151+
eessiDebug("Using site acclerator modules at: " .. eessi_module_path_site_accel)
147152
end
148153
end
149154

0 commit comments

Comments
 (0)