Skip to content

Commit

Permalink
Merge pull request #20 from smoors/dummy_module
Browse files Browse the repository at this point in the history
create dummy modules for CUDA software on non-GPU nodes #AB21702
  • Loading branch information
lexming authored May 23, 2024
2 parents f12bc62 + 38628b6 commit 30af029
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
41 changes: 40 additions & 1 deletion lib/vsc/eb_hooks/hooks_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"""

import os
from distutils.version import LooseVersion

from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS
from easybuild.tools import LooseVersion
from easybuild.tools.hooks import SANITYCHECK_STEP

from vsc.eb_hooks.ib_modules import IB_MODULE_SOFTWARE, IB_MODULE_SUFFIX, IB_OPT_MARK

Expand All @@ -48,6 +49,9 @@
'VASP': 'bvasp',
}

GPU_ARCHS = ['zen2', 'broadwell']
IS_CUDA_SOFTWARE = False


def parse_hook(ec, *args, **kwargs): # pylint: disable=unused-argument
"""Alter the parameters of easyconfigs"""
Expand Down Expand Up @@ -119,6 +123,20 @@ def parse_hook(ec, *args, **kwargs): # pylint: disable=unused-argument
ec.log.info(f"[parse hook] Set optarch in parameter toolchainopts: {ec.toolchain.options['optarch']}")


def pre_fetch_hook(self, *args, **kwargs): # pylint: disable=unused-argument
"""Hook at pre-fetch level"""

# skip installation of CUDA software in non-GPU architectures, only create module file
global IS_CUDA_SOFTWARE
IS_CUDA_SOFTWARE = 'CUDA' in self.name or 'CUDA' in self.cfg['versionsuffix']
if IS_CUDA_SOFTWARE and os.environ['VSC_ARCH_LOCAL'] not in GPU_ARCHS:
# module_only steps: [MODULE_STEP, PREPARE_STEP, READY_STEP, POSTITER_STEP, SANITYCHECK_STEP]
self.cfg['module_only'] = True
self.log.info(f"[pre-fetch hook] Set parameter module_only: {self.cfg['module_only']}")
self.cfg['skipsteps'] = [SANITYCHECK_STEP]
self.log.info(f"[pre-fetch hook] Set parameter skipsteps: {self.cfg['skipsteps']}")


def pre_configure_hook(self, *args, **kwargs): # pylint: disable=unused-argument
"""Hook at pre-configure level to alter configopts"""

Expand Down Expand Up @@ -327,4 +345,25 @@ def pre_module_hook(self, *args, **kwargs): # pylint: disable=unused-argument
else:
self.cfg['docurls'] = [usage_info['link']]

#################################
# ------ DUMMY MODULES -------- #
#################################

if IS_CUDA_SOFTWARE and os.environ['VSC_ARCH_LOCAL'] not in GPU_ARCHS:
self.log.info("[pre-module hook] Creating dummy module for CUDA modules on non-GPU nodes")
self.cfg['modluafooter'] = """
if mode() == "load" and not os.getenv("VUB_HPC_BUILD") then
LmodError([[
This module is only available on nodes with a GPU.
Jobs can request GPUs with the command 'srun --gpus-per-node=1' or 'sbatch --gpus-per-node=1'.
More information in the VUB-HPC docs:
https://hpc.vub.be/docs/job-submission/gpu-job-types/#gpu-jobs
]])
end"""

############################
# ------ FINALIZE -------- #
############################

self.cfg.enable_templating = en_templ
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


PACKAGE = {
'version': '1.4.0',
'version': '1.5.0',
'author': [ad, sm, wp],
'maintainer': [ad, sm, wp],
'setup_requires': [
Expand Down

0 comments on commit 30af029

Please sign in to comment.