Skip to content

Commit 8459c5c

Browse files
authored
Merge pull request #2225 from Flamefire/tf2.4
Update TensorFlow easyblock for TensorFlow 2.4
2 parents 3df929a + b58ff90 commit 8459c5c

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

easybuild/easyblocks/t/tensorflow.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ def is_version_ok(version_range):
148148
('NASM', '2.0.0:'): 'nasm',
149149
('nsync', '2.0.0:'): 'nsync',
150150
('PCRE', '2.0.0:'): 'pcre',
151-
('protobuf-python', '2.0.0:'): 'com_google_protobuf',
151+
('protobuf', '2.0.0:'): 'com_google_protobuf',
152152
('pybind11', '2.2.0:'): 'pybind11',
153153
('snappy', '2.0.0:'): 'snappy',
154154
('SQLite', '2.0.0:'): 'org_sqlite',
155-
('SWIG', '2.0.0:'): 'swig',
155+
('SWIG', '2.0.0:2.4.0'): 'swig',
156156
('zlib', '2.0.0:2.2.0'): 'zlib_archive',
157157
('zlib', '2.2.0:'): 'zlib',
158158
}
@@ -174,14 +174,19 @@ def is_version_ok(version_range):
174174
('astor', '2.0.0:'): 'astor_archive',
175175
('astunparse', '2.2.0:'): 'astunparse_archive',
176176
('cython', '2.0.0:'): 'cython', # Part of Python EC
177+
('dill', '2.4.0:'): 'dill_archive',
177178
('enum', '2.0.0:'): 'enum34_archive', # Part of Python3
179+
('flatbuffers', '2.4.0:'): 'flatbuffers',
178180
('functools', '2.0.0:'): 'functools32_archive', # Part of Python3
179181
('gast', '2.0.0:'): 'gast_archive',
182+
('google.protobuf', '2.0.0:'): 'com_google_protobuf',
180183
('keras_applications', '2.0.0:2.2.0'): 'keras_applications_archive',
181184
('opt_einsum', '2.0.0:'): 'opt_einsum_archive',
182185
('pasta', '2.0.0:'): 'pasta',
183186
('six', '2.0.0:'): 'six_archive', # Part of Python EC
187+
('tblib', '2.4.0:'): 'tblib_archive',
184188
('termcolor', '2.0.0:'): 'termcolor_archive',
189+
('typing_extensions', '2.4.0:'): 'typing_extensions_archive',
185190
('wrapt', '2.0.0:'): 'wrapt',
186191
}
187192
dependency_mapping = dict((dep_name, tf_name)
@@ -348,6 +353,9 @@ def get_system_libs(self):
348353
Returns a tuple of lists: $TF_SYSTEM_LIBS names, include paths, library paths
349354
"""
350355
dependency_mapping, python_mapping = get_system_libs_for_version(self.version)
356+
# Some TF dependencies require both a (usually C++) dependency and a Python package
357+
deps_with_python_pkg = set(tf_name for tf_name in dependency_mapping.values()
358+
if tf_name in python_mapping.values())
351359

352360
system_libs = []
353361
cpaths = []
@@ -358,15 +366,17 @@ def get_system_libs(self):
358366
dep_names = set(dep['name'] for dep in self.cfg.dependencies())
359367
for dep_name, tf_name in sorted(dependency_mapping.items(), key=lambda i: i[0].lower()):
360368
if dep_name in dep_names:
369+
if tf_name in deps_with_python_pkg:
370+
pkg_name = next(cur_pkg_name for cur_pkg_name, cur_tf_name in python_mapping.items()
371+
if cur_tf_name == tf_name)
372+
# Simply ignore. Error reporting is done in the other loop
373+
if not self.python_pkg_exists(pkg_name):
374+
continue
361375
system_libs.append(tf_name)
362376
# When using cURL (which uses the system OpenSSL), we also need to use "boringssl"
363377
# which essentially resolves to using OpenSSL as the API and library names are compatible
364378
if dep_name == 'cURL':
365379
system_libs.append('boringssl')
366-
# For protobuf we need protobuf and protobuf-python where the latter depends on the former
367-
# For includes etc. we need to get the values from protobuf
368-
if dep_name == 'protobuf-python':
369-
dep_name = 'protobuf'
370380
sw_root = get_software_root(dep_name)
371381
# Dependency might be filtered via --filter-deps. In that case assume globally installed version
372382
if not sw_root:
@@ -379,9 +389,12 @@ def get_system_libs(self):
379389
# https://github.com/tensorflow/tensorflow/issues/42303
380390
cpaths.append(sw_root)
381391
if dep_name == 'protobuf':
382-
# Need to set INCLUDEDIR as TF wants to symlink headers from there:
383-
# https://github.com/tensorflow/tensorflow/issues/37835
384-
env.setvar('INCLUDEDIR', incpath)
392+
if LooseVersion(self.version) < LooseVersion('2.4'):
393+
# Need to set INCLUDEDIR as TF wants to symlink files from there:
394+
# https://github.com/tensorflow/tensorflow/issues/37835
395+
env.setvar('INCLUDEDIR', incpath)
396+
else:
397+
env.setvar('PROTOBUF_INCLUDE_PATH', incpath)
385398
libpath = get_software_libdir(dep_name)
386399
if libpath:
387400
libpaths.append(os.path.join(sw_root, libpath))
@@ -390,7 +403,9 @@ def get_system_libs(self):
390403

391404
for pkg_name, tf_name in sorted(python_mapping.items(), key=lambda i: i[0].lower()):
392405
if self.python_pkg_exists(pkg_name):
393-
system_libs.append(tf_name)
406+
# If it is in deps_with_python_pkg we already added it
407+
if tf_name not in deps_with_python_pkg:
408+
system_libs.append(tf_name)
394409
else:
395410
ignored_system_deps.append('%s (Python package %s)' % (tf_name, pkg_name))
396411

0 commit comments

Comments
 (0)