From 6a866b70bb34608239fa09ab49aabe802443db29 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 18 Oct 2022 11:10:45 +0200 Subject: [PATCH 1/2] create $XDG_CACHE_HOME for PyTorch tests The path must exist or PyTorch will show errors/warnings like: > UserWarning: Specified kernel cache directory could not be created! This disables kernel caching. --- easybuild/easyblocks/p/pytorch.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/easybuild/easyblocks/p/pytorch.py b/easybuild/easyblocks/p/pytorch.py index ec4ee9ad97..32ef1e3231 100644 --- a/easybuild/easyblocks/p/pytorch.py +++ b/easybuild/easyblocks/p/pytorch.py @@ -37,7 +37,7 @@ from easybuild.framework.easyconfig import CUSTOM from easybuild.tools.build_log import EasyBuildError, print_warning from easybuild.tools.config import build_option -from easybuild.tools.filetools import symlink, apply_regex_substitutions +from easybuild.tools.filetools import symlink, apply_regex_substitutions, mkdir from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.systemtools import POWER, get_cpu_architecture @@ -239,10 +239,16 @@ def configure_step(self): self.cfg.update('prebuildopts', ' '.join(unique_options) + ' ') self.cfg.update('preinstallopts', ' '.join(unique_options) + ' ') + def _set_cache_dir(self): + """Set $XDG_CACHE_HOME to avoid PyTorch defaulting to $HOME""" + cache_dir = os.path.join(self.tmpdir, '.cache') + # The path must exist! + mkdir(cache_dir, parents=True) + env.setvar('XDG_CACHE_HOME', cache_dir) + def test_step(self): """Run unit tests""" - # Make PyTorch tests not use the user home - env.setvar('XDG_CACHE_HOME', os.path.join(self.tmpdir, '.cache')) + self._set_cache_dir() # Pretend to be on FB CI which disables some tests, especially those which download stuff env.setvar('SANDCASTLE', '1') # Skip this test(s) which is very flaky @@ -350,8 +356,7 @@ def get_count_for_pattern(regex, text): raise EasyBuildError("Test command had non-zero exit code (%s), but no failed tests found?!", tests_ec) def test_cases_step(self): - # Make PyTorch tests not use the user home - env.setvar('XDG_CACHE_HOME', os.path.join(self.tmpdir, '.cache')) + self._set_cache_dir() super(EB_PyTorch, self).test_cases_step() def sanity_check_step(self, *args, **kwargs): From 58a7a05622e219e69ed33794f5836cc660c12774 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Tue, 18 Oct 2022 20:07:19 +0200 Subject: [PATCH 2/2] fix alphabetical order for filetools imports in PyTorch easyblock --- easybuild/easyblocks/p/pytorch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/p/pytorch.py b/easybuild/easyblocks/p/pytorch.py index 32ef1e3231..31c70c9a4d 100644 --- a/easybuild/easyblocks/p/pytorch.py +++ b/easybuild/easyblocks/p/pytorch.py @@ -37,7 +37,7 @@ from easybuild.framework.easyconfig import CUSTOM from easybuild.tools.build_log import EasyBuildError, print_warning from easybuild.tools.config import build_option -from easybuild.tools.filetools import symlink, apply_regex_substitutions, mkdir +from easybuild.tools.filetools import apply_regex_substitutions, mkdir, symlink from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.systemtools import POWER, get_cpu_architecture