Skip to content

Commit 5ca4109

Browse files
committed
Avoid writes to $HOME from Triton during PyTorch tests
1 parent 6a53273 commit 5ca4109

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

easybuild/easyblocks/p/pytorch.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,16 @@ def add_enable_option(name, enabled):
539539
self.cfg.update('preinstallopts', ' '.join(unique_options) + ' ')
540540

541541
def _set_cache_dir(self):
542-
"""Set $XDG_CACHE_HOME to avoid PyTorch defaulting to $HOME"""
542+
"""Set $XDG_CACHE_HOME and $TRITON_HOME to avoid PyTorch defaulting to $HOME"""
543543
cache_dir = os.path.join(self.tmpdir, '.cache')
544544
# The path must exist!
545545
mkdir(cache_dir, parents=True)
546546
env.setvar('XDG_CACHE_HOME', cache_dir)
547+
# Triton also uses a path defaulting to $HOME
548+
# Isolate against user-set variables
549+
env.unset_env_vars(var for var in os.environ if var.startswith('TRITON_'))
550+
triton_home = os.path.join(self.tmpdir, '.triton_home')
551+
env.setvar('TRITON_HOME', triton_home)
547552

548553
def _compare_test_results(self, old_result, xml_result, old_failed_test_names, xml_failed_test_names):
549554
"""Compare test results parsed from stdout and XML files"""

0 commit comments

Comments
 (0)