Skip to content

Commit 977d319

Browse files
committed
fix cuddn hook for non eessi installation
1 parent 8890817 commit 977d319

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):
@@ -973,7 +973,7 @@ def post_postproc_cuda(self, *args, **kwargs):
973973
and replace them with a symlink to a corresponding installation under host_injections.
974974
"""
975975
if self.name == 'CUDA':
976-
# This hook only acts on an installation under repositories that _we_ ship (*.eessi.io/versions)
976+
# This hook only acts on an installation under repositories that _we_ ship (*.eessi.io/versions)
977977
eessi_installation = bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir))
978978

979979
if eessi_installation:
@@ -1032,43 +1032,46 @@ def post_postproc_cudnn(self, *args, **kwargs):
10321032
and replace them with a symlink to a corresponding installation under host_injections.
10331033
"""
10341034

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

0 commit comments

Comments
 (0)