Skip to content

Commit 339d20a

Browse files
authored
Merge pull request #3751 from Flamefire/tensorflow-tmp-home
Set `$HOME` to temporary folder for TensorFlow build and tests
2 parents f9eb157 + 2810fbd commit 339d20a

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

easybuild/easyblocks/t/tensorflow.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ def is_version_ok(version_range):
197197
('wrapt', '2.0.0:'): 'wrapt',
198198
}
199199

200-
dependency_mapping = dict((dep_name, tf_name)
201-
for (dep_name, version_range), tf_name in available_system_libs.items()
202-
if is_version_ok(version_range))
203-
python_mapping = dict((pkg_name, tf_name)
204-
for (pkg_name, version_range), tf_name in python_system_libs.items()
205-
if is_version_ok(version_range))
200+
dependency_mapping = {dep_name: tf_name
201+
for (dep_name, version_range), tf_name in available_system_libs.items()
202+
if is_version_ok(version_range)}
203+
python_mapping = {pkg_name: tf_name
204+
for (pkg_name, version_range), tf_name in python_system_libs.items()
205+
if is_version_ok(version_range)}
206206

207207
if as_valid_libs:
208208
tf_names = [tf_name for tf_name, version_range in unused_system_libs.items()
@@ -356,16 +356,16 @@ def get_system_libs(self):
356356
"""
357357
dependency_mapping, python_mapping = get_system_libs_for_version(self.version)
358358
# Some TF dependencies require both a (usually C++) dependency and a Python package
359-
deps_with_python_pkg = set(tf_name for tf_name in dependency_mapping.values()
360-
if tf_name in python_mapping.values())
359+
deps_with_python_pkg = {tf_name for tf_name in dependency_mapping.values()
360+
if tf_name in python_mapping.values()}
361361

362362
system_libs = []
363363
cpaths = []
364364
libpaths = []
365365
ignored_system_deps = []
366366

367367
# Check direct dependencies
368-
dep_names = set(dep['name'] for dep in self.cfg.dependencies())
368+
dep_names = {dep['name'] for dep in self.cfg.dependencies()}
369369
for dep_name, tf_name in sorted(dependency_mapping.items(), key=lambda i: i[0].lower()):
370370
if dep_name in dep_names:
371371
if tf_name in deps_with_python_pkg:
@@ -446,6 +446,8 @@ def setup_build_dirs(self):
446446
parent_dir = os.path.dirname(self.start_dir)
447447
# Path where Bazel will store its output, build artefacts etc.
448448
self.output_user_root_dir = os.path.join(parent_dir, 'bazel-root')
449+
# Replace $HOME with a temporary folder to avoid using the user's home directory
450+
self.home_dir = tempfile.mkdtemp(suffix='-tf-home')
449451
# Folder where wrapper binaries can be placed, where required. TODO: Replace by --action_env cmds
450452
self.wrapper_dir = os.path.join(parent_dir, 'wrapper_bin')
451453
mkdir(self.wrapper_dir)
@@ -817,7 +819,7 @@ def patch_crosstool_files(self):
817819
regex_subs.extend([('-fPIE', '-fPIC'), ('"-pie"', '"-fPIC"')])
818820

819821
# patch all CROSSTOOL* scripts to fix hardcoding of locations of binutils/GCC binaries
820-
for path, dirnames, filenames in os.walk(os.getcwd()):
822+
for path, _dirnames, filenames in os.walk(os.getcwd()):
821823
for filename in filenames:
822824
if filename.startswith('CROSSTOOL'):
823825
full_path = os.path.join(path, filename)
@@ -849,6 +851,8 @@ def build_step(self):
849851
# A value of None is interpreted as using the invoking environments value
850852
INHERIT = None # For better readability
851853

854+
action_env['HOME'] = self.home_dir
855+
852856
jvm_max_memory = self.cfg['jvm_max_memory']
853857
if jvm_max_memory:
854858
jvm_startup_memory = min(512, int(jvm_max_memory))
@@ -1116,7 +1120,7 @@ def test_step(self):
11161120
self.log.warning(fail_msg)
11171121
# Try to enhance error message
11181122
failed_tests = []
1119-
failed_test_logs = dict()
1123+
failed_test_logs = {}
11201124
# Bazel outputs failed tests like "//tensorflow/c:kernels_test FAILED in[...]"
11211125
for match in re.finditer(r'^(//[a-zA-Z_/:]+)\s+FAILED', res.output, re.MULTILINE):
11221126
test_name = match.group(1)

0 commit comments

Comments
 (0)