Skip to content

Commit e22f293

Browse files
authored
Merge pull request #1109 from ocaisa/limit_cuda_installs
Limit accelerator installations to GPU only
2 parents 4e6b3a2 + 7474c53 commit e22f293

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

eb_hooks.py

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

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

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

0 commit comments

Comments
 (0)