Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create dummy modules for CUDA software on non-GPU nodes #AB21702 #20

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
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
Loading