Skip to content

Commit

Permalink
add hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lara committed Sep 27, 2023
1 parent 96af85e commit e61c869
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ def parse_hook(ec, *args, **kwargs):
if ec.name in PARSE_HOOKS:
PARSE_HOOKS[ec.name](ec, eprefix)

def post_ready_hook(self, *args, **kwargs):
"""
Post-ready hook: limit parallellism for selected builds, because they require a lot of memory per used core.
"""
# 'parallel' easyconfig parameter is set via EasyBlock.set_parallel in ready step based on available cores.
# here we reduce parallellism to only use half of that for selected software,
# to avoid failing builds/tests due to out-of-memory problems
if self.name in ['TensorFlow']:
parallel = self.cfg['parallel']
if parallel > 1:
self.cfg['parallel'] = parallel // 2
msg = "limiting parallelism to %s (was %s) for %s to avoid out-of-memory failures during building/testing"
print_msg(msg % (self.cfg['parallel'], parallel, self.name), log=self.log)


def pre_prepare_hook(self, *args, **kwargs):
"""Main pre-prepare hook: trigger custom functions."""
Expand Down

0 comments on commit e61c869

Please sign in to comment.