Skip to content

Commit 5b9657a

Browse files
authored
Merge pull request #172 from bedroge/pytorch_glibc241_execstack
add pre_prepare hook for Pytorch which solves executable stack errors
2 parents c481bc1 + a4e9303 commit 5b9657a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

eb_hooks.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,28 @@ def pre_prepare_hook_llvm_a64fx(self, *args, **kwargs):
978978
update_build_option('optarch', 'march=armv8.2-a')
979979

980980

981+
def pre_prepare_hook_pytorch(self, *args, **kwargs):
982+
"""
983+
Solve PyTorch test failures due to:
984+
cannot enable executable stack as shared object requires: Invalid argument
985+
986+
Glibc prevents loading of shared libraries with an executable stack.
987+
We can work around it by reverting to old behavior by setting glibc.rtld.execstack=2,
988+
which forces the stack to be executable at process startup.
989+
See:
990+
https://github.com/ValveSoftware/Source-1-Games/issues/6982
991+
https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/issues/19
992+
https://sourceware.org/bugzilla/show_bug.cgi?id=32653
993+
"""
994+
if self.name == 'PyTorch':
995+
if self.version in ['2.6.0', '2.7.1', '2.9.1']:
996+
eessi_version = get_eessi_envvar('EESSI_VERSION')
997+
if eessi_version == '2025.06':
998+
os.environ['GLIBC_TUNABLES'] = 'glibc.rtld.execstack=2'
999+
else:
1000+
raise EasyBuildError("PyTorch-specific hook triggered for non-PyTorch easyconfig?!")
1001+
1002+
9811003
def post_prepare_hook_llvm_a64fx(self, *args, **kwargs):
9821004
"""
9831005
Post-prepare hook for LLVM 14 and 15 on A64FX to reset optarch build option.
@@ -1904,6 +1926,7 @@ def post_easyblock_hook(self, *args, **kwargs):
19041926
'cuDNN': pre_prepare_hook_cudnn,
19051927
'Highway': pre_prepare_hook_highway_handle_test_compilation_issues,
19061928
'LLVM': pre_prepare_hook_llvm_a64fx,
1929+
'PyTorch': pre_prepare_hook_pytorch,
19071930
'Rust': pre_prepare_hook_llvm_a64fx,
19081931
}
19091932

0 commit comments

Comments
 (0)