Skip to content

Commit 31daf13

Browse files
authored
Merge pull request #1099 from pescobar/fix-cuddn-hook
fix cudnn hook for non eessi installation
2 parents e0c6d63 + 893173a commit 31daf13

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

eb_hooks.py

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def parse_hook_freeimage_aarch64(ec, *args, **kwargs):
390390
ec['toolchainopts'] = {}
391391
ec['toolchainopts']['pic'] = True
392392
ec['toolchainopts']['extra_cflags'] = '-DPNG_ARM_NEON_OPT=0'
393-
print_msg("Changed toolchainopts for %s: %s", ec.name, ec['toolchainopts'])
393+
print_msg("Changed toolchainopts for %s: %s", ec.name, ec['toolchainopts'])
394394

395395

396396
def parse_hook_zen4_module_only(ec, eprefix):
@@ -989,7 +989,7 @@ def post_postproc_cuda(self, *args, **kwargs):
989989
and replace them with a symlink to a corresponding installation under host_injections.
990990
"""
991991
if self.name == 'CUDA':
992-
# This hook only acts on an installation under repositories that _we_ ship (*.eessi.io/versions)
992+
# This hook only acts on an installation under repositories that _we_ ship (*.eessi.io/versions)
993993
eessi_installation = bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir))
994994

995995
if eessi_installation:
@@ -1048,43 +1048,46 @@ def post_postproc_cudnn(self, *args, **kwargs):
10481048
and replace them with a symlink to a corresponding installation under host_injections.
10491049
"""
10501050

1051-
# We need to check if we are doing an EESSI-distributed installation
1052-
eessi_installation = bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir))
1053-
1054-
if self.name == 'cuDNN' and eessi_installation:
1055-
print_msg("Replacing files in cuDNN installation that we can not ship with symlinks to host_injections...")
1056-
1057-
allowlist = ['LICENSE']
1058-
1059-
# read cuDNN LICENSE, construct allowlist based on section "2. Distribution" that specifies list of files that can be shipped
1060-
license_path = os.path.join(self.installdir, 'LICENSE')
1061-
search_string = "2. Distribution. The following portions of the SDK are distributable under the Agreement:"
1062-
found_search_string = False
1063-
with open(license_path) as infile:
1064-
for line in infile:
1065-
if line.strip().startswith(search_string):
1066-
found_search_string = True
1067-
# remove search string, split into words, remove trailing
1068-
# dots '.' and only retain words starting with a dot '.'
1069-
distributable = line[len(search_string):]
1070-
# distributable looks like ' the runtime files .so and .dll.'
1071-
# note the '.' after '.dll'
1072-
for word in distributable.split():
1073-
if word[0] == '.':
1074-
# rstrip is used to remove the '.' after '.dll'
1075-
allowlist.append(word.rstrip('.'))
1076-
if not found_search_string:
1077-
# search string wasn't found in LICENSE file
1078-
raise EasyBuildError("search string '%s' was not found in license file '%s';"
1079-
"hence installation may be replaced by symlinks only",
1080-
search_string, license_path)
1081-
1082-
allowlist = sorted(set(allowlist))
1083-
self.log.info("Allowlist for files in cuDNN installation that can be redistributed: " + ', '.join(allowlist))
1084-
1085-
# replace files that are not distributable with symlinks into
1086-
# host_injections
1087-
replace_non_distributable_files_with_symlinks(self.log, self.installdir, self.name, allowlist)
1051+
if self.name == 'cuDNN':
1052+
# This hook only acts on an installation under repositories that _we_ ship (*.eessi.io/versions)
1053+
eessi_installation = bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir))
1054+
1055+
if eessi_installation:
1056+
print_msg("Replacing files in cuDNN installation that we can not ship with symlinks to host_injections...")
1057+
1058+
allowlist = ['LICENSE']
1059+
1060+
# read cuDNN LICENSE, construct allowlist based on section "2. Distribution" that specifies list of files that can be shipped
1061+
license_path = os.path.join(self.installdir, 'LICENSE')
1062+
search_string = "2. Distribution. The following portions of the SDK are distributable under the Agreement:"
1063+
found_search_string = False
1064+
with open(license_path) as infile:
1065+
for line in infile:
1066+
if line.strip().startswith(search_string):
1067+
found_search_string = True
1068+
# remove search string, split into words, remove trailing
1069+
# dots '.' and only retain words starting with a dot '.'
1070+
distributable = line[len(search_string):]
1071+
# distributable looks like ' the runtime files .so and .dll.'
1072+
# note the '.' after '.dll'
1073+
for word in distributable.split():
1074+
if word[0] == '.':
1075+
# rstrip is used to remove the '.' after '.dll'
1076+
allowlist.append(word.rstrip('.'))
1077+
if not found_search_string:
1078+
# search string wasn't found in LICENSE file
1079+
raise EasyBuildError("search string '%s' was not found in license file '%s';"
1080+
"hence installation may be replaced by symlinks only",
1081+
search_string, license_path)
1082+
1083+
allowlist = sorted(set(allowlist))
1084+
self.log.info("Allowlist for files in cuDNN installation that can be redistributed: " + ', '.join(allowlist))
1085+
1086+
# replace files that are not distributable with symlinks into
1087+
# host_injections
1088+
replace_non_distributable_files_with_symlinks(self.log, self.installdir, self.name, allowlist)
1089+
else:
1090+
print_msg(f"EESSI hook to respect cuDDN license not triggered for installation path {self.installdir}")
10881091
else:
10891092
raise EasyBuildError("cuDNN-specific hook triggered for non-cuDNN easyconfig?!")
10901093

0 commit comments

Comments
 (0)