Skip to content

Commit 236d273

Browse files
authored
Merge pull request #2293 from Flamefire/tf_reduce_dirs
create less temporary directories for TensorFlow by (only) using --output_user_root
2 parents 148e830 + 9b33659 commit 236d273

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

easybuild/easyblocks/t/tensorflow.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,10 @@ def get_system_libs(self):
430430

431431
def setup_build_dirs(self):
432432
"""Setup temporary build directories"""
433-
# Tensorflow/Bazel needs a couple of directories where it stores build cache and artefacts
434-
tmpdir = tempfile.mkdtemp(suffix='-bazel-tf', dir=self.builddir)
435-
self.output_root_dir = os.path.join(tmpdir, 'output_root')
436-
self.output_base_dir = os.path.join(tmpdir, 'output_base')
437-
self.output_user_root_dir = os.path.join(tmpdir, 'output_user_root')
438-
self.wrapper_dir = os.path.join(tmpdir, 'wrapper_bin')
439-
# This (likely) needs to be a subdir of output_base
440-
self.install_base_dir = os.path.join(self.output_base_dir, 'inst_base')
433+
# Path where Bazel will store its output, build artefacts etc.
434+
self.output_user_root_dir = tempfile.mkdtemp(suffix='-bazel-tf', dir=self.builddir)
435+
# Folder where wrapper binaries can be placed, where required. TODO: Replace by --action_env cmds
436+
self.wrapper_dir = tempfile.mkdtemp(suffix='-wrapper_bin', dir=self.builddir)
441437

442438
def configure_step(self):
443439
"""Custom configuration procedure for TensorFlow."""
@@ -640,17 +636,14 @@ def configure_step(self):
640636
for (key, val) in sorted(config_env_vars.items()):
641637
env.setvar(key, val)
642638

643-
# Does no longer apply (and might not be required at all) since 1.12.0
644-
if LooseVersion(self.version) < LooseVersion('1.12.0'):
645-
# patch configure.py (called by configure script) to avoid that Bazel abuses $HOME/.cache/bazel
646-
regex_subs = [(r"(run_shell\(\['bazel')",
647-
r"\1, '--output_base=%s', '--install_base=%s'" % (self.output_base_dir,
648-
self.install_base_dir))]
639+
# configure.py (called by configure script) already calls bazel to determine the bazel version
640+
# Since 2.3.0 `bazel --version` is used which doesn't extract bazel, prior it did
641+
# Hence make sure it doesn't extract into $HOME/.cache/bazel
642+
if LooseVersion(self.version) < LooseVersion('2.3.0'):
643+
regex_subs = [(r"('bazel', '--batch')",
644+
r"\1, '--output_user_root=%s'" % self.output_user_root_dir)]
649645
apply_regex_substitutions('configure.py', regex_subs)
650646

651-
# Tell Bazel to not use $HOME/.cache/bazel at all
652-
# See https://docs.bazel.build/versions/master/output_directories.html
653-
env.setvar('TEST_TMPDIR', self.output_root_dir)
654647
cmd = self.cfg['preconfigopts'] + './configure ' + self.cfg['configopts']
655648
run_cmd(cmd, log_all=True, simple=True)
656649

@@ -733,8 +726,6 @@ def build_step(self):
733726

734727
# Options passed to the bazel command
735728
self.bazel_opts = [
736-
'--output_base=%s' % self.output_base_dir,
737-
'--install_base=%s' % self.install_base_dir,
738729
'--output_user_root=%s' % self.output_user_root_dir,
739730
]
740731
jvm_max_memory = self.cfg['jvm_max_memory']

0 commit comments

Comments
 (0)