Skip to content

Commit 1dde142

Browse files
committed
Restrict GPU installs to accelerator paths only
1 parent fd6dc51 commit 1dde142

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

eb_hooks.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from easybuild.tools.systemtools import AARCH64, POWER, X86_64, get_cpu_architecture, get_cpu_features
1515
from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC
1616
from easybuild.tools.version import VERSION as EASYBUILD_VERSION
17-
from easybuild.tools.modules import get_software_root_env_var_name
1817

1918
# prefer importing LooseVersion from easybuild.tools, but fall back to distuils in case EasyBuild <= 4.7.0 is used
2019
try:
@@ -422,6 +421,37 @@ def pre_fetch_hook(self, *args, **kwargs):
422421
if cpu_target == CPU_TARGET_ZEN4:
423422
pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs)
424423

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+
425455

426456
def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs):
427457
"""Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4.
@@ -671,27 +701,6 @@ def pre_configure_hook_gromacs(self, *args, **kwargs):
671701
raise EasyBuildError("GROMACS-specific hook triggered for non-GROMACS easyconfig?!")
672702

673703

674-
def pre_configure_hook_llvm(self, *args, **kwargs):
675-
"""Adjust internal configure options for the LLVM EasyBlock to reinstate filtered out dependencies.
676-
In the LLVM EasyBlock, most checks concerning loaded modules are performed at the configure_step.
677-
The EB uses a global `general_opts` dict to keep track of options that needs to be reused across stages.
678-
The way the EB is structured does allow to inject a CMAKE option through `self._cfgopts` which is a splitted list
679-
of the `configure_opts` passed through the EC, but does not allow to override as the `general_opts` dict will
680-
take precedence over the `self._cfgopts` list.
681-
682-
We can instead set the environment variable that EasyBuild uses for `get_software_root` to trick the EB into
683-
into pointing to the compat layer.
684-
"""
685-
if self.name in ['LLVM', 'ROCm-LLVM']:
686-
eprefix = get_eessi_envvar('EPREFIX')
687-
688-
for software in ('zlib', 'ncurses'):
689-
var_name = get_software_root_env_var_name(software)
690-
env.setvar(var_name, os.path.join(eprefix, 'usr'))
691-
else:
692-
raise EasyBuildError("LLVM-specific hook triggered for non-LLVM easyconfig?!")
693-
694-
695704
def pre_configure_hook_openblas_optarch_generic(self, *args, **kwargs):
696705
"""
697706
Pre-configure hook for OpenBLAS: add DYNAMIC_ARCH=1 to build/test/install options when using --optarch=GENERIC
@@ -1279,8 +1288,6 @@ def post_module_hook(self, *args, **kwargs):
12791288
'Extrae': pre_configure_hook_extrae,
12801289
'GROMACS': pre_configure_hook_gromacs,
12811290
'libfabric': pre_configure_hook_libfabric_disable_psm3_x86_64_generic,
1282-
'LLVM': pre_configure_hook_llvm,
1283-
'ROCm-LLVM': pre_configure_hook_llvm,
12841291
'MetaBAT': pre_configure_hook_metabat_filtered_zlib_dep,
12851292
'OpenBLAS': pre_configure_hook_openblas_optarch_generic,
12861293
'WRF': pre_configure_hook_wrf_aarch64,

0 commit comments

Comments
 (0)