Skip to content

Commit d21f92e

Browse files
committed
add hook that solves PyTorch executable stack errors
1 parent 54a2498 commit d21f92e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

eb_hooks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,27 @@ def pre_prepare_hook_llvm_a64fx(self, *args, **kwargs):
940940
update_build_option('optarch', 'march=armv8.2-a')
941941

942942

943+
def pre_prepare_hook_pytorch(self, *args, **kwargs):
944+
"""
945+
Solve PyTorch test failures due to:
946+
cannot enable executable stack as shared object requires: Invalid argument
947+
948+
Glibc prevents loading of shared libraries with an executable stack.
949+
We can work around it by reverting to old behavior by setting glibc.rtld.execstack=2.
950+
See:
951+
https://github.com/ValveSoftware/Source-1-Games/issues/6982
952+
https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/issues/19
953+
https://sourceware.org/bugzilla/show_bug.cgi?id=32653
954+
"""
955+
if self.name == 'PyTorch':
956+
if self.version in ['2.6.0', '2.7.1', '2.9.1']:
957+
eessi_version = get_eessi_envvar('EESSI_VERSION')
958+
if self.eessi_version == '2025.06':
959+
os.environ['GLIBC_TUNABLES=glibc.rtld.execstack'] = '2'
960+
else:
961+
raise EasyBuildError("PyTorch-specific hook triggered for non-PyTorch easyconfig?!")
962+
963+
943964
def post_prepare_hook_llvm_a64fx(self, *args, **kwargs):
944965
"""
945966
Post-prepare hook for LLVM 14 and 15 on A64FX to reset optarch build option.
@@ -1866,6 +1887,7 @@ def post_easyblock_hook(self, *args, **kwargs):
18661887
'cuDNN': pre_prepare_hook_cudnn,
18671888
'Highway': pre_prepare_hook_highway_handle_test_compilation_issues,
18681889
'LLVM': pre_prepare_hook_llvm_a64fx,
1890+
'PyTorch': pre_prepare_hook_pytorch,
18691891
'Rust': pre_prepare_hook_llvm_a64fx,
18701892
}
18711893

0 commit comments

Comments
 (0)