From 8e3592c5048e3828ea5db5a5024a82e577a90694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Andr=C3=A9=20Reuter?= Date: Fri, 9 Jan 2026 23:26:02 +0100 Subject: [PATCH 1/2] Allow to specify env for GPU info and use it for test reports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tools like `amd-smi` and `rocm-smi` rely on having a clean environment to correctly pick up information. However, the last build in `build_and_install_software` leaves a tampered environment from the last build, breaking both commands. To still correctly determine the GPU information, introduce a variable allowing to use the initial environment instead. Also use this for `nvidia-smi`, as its, by now, typically installed on the system level and not as a module. Signed-off-by: Jan André Reuter --- easybuild/tools/systemtools.py | 13 ++++++++----- easybuild/tools/testing.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/easybuild/tools/systemtools.py b/easybuild/tools/systemtools.py index 5b9b2f7c7a..dfe74c8996 100644 --- a/easybuild/tools/systemtools.py +++ b/easybuild/tools/systemtools.py @@ -670,9 +670,12 @@ def get_isa_riscv(): return isa_string -def get_gpu_info(): +def get_gpu_info(environment=None): """ Get the GPU info + + :param environment: The environment to be used for determining GPU information. + By default, inherit the processes' environment. """ if get_os_type() != LINUX: _log.info("Only know how to get GPU info on Linux, assuming no GPUs are present") @@ -686,7 +689,7 @@ def get_gpu_info(): cmd = "nvidia-smi --query-gpu=gpu_name,driver_version --format=csv,noheader" _log.debug("Trying to determine NVIDIA GPU info on Linux via cmd '%s'", cmd) res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False, - output_file=False, stream_output=False) + output_file=False, stream_output=False, env=environment) if res.exit_code == EasyBuildExit.SUCCESS: for line in res.output.strip().split('\n'): nvidia_gpu_info = gpu_info.setdefault('NVIDIA', {}) @@ -706,7 +709,7 @@ def get_gpu_info(): cmd = "amd-smi static --driver --board --asic --csv" _log.debug("Trying to determine AMD GPU info on Linux via cmd '%s'", cmd) res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False, - output_file=False, stream_output=False, split_stderr=True) + output_file=False, stream_output=False, split_stderr=True, env=environment) if res.exit_code == EasyBuildExit.SUCCESS: csv_reader = csv.DictReader(io.StringIO(res.output.strip())) @@ -737,14 +740,14 @@ def get_gpu_info(): cmd = "rocm-smi --showdriverversion --csv" _log.debug("Trying to determine AMD GPU driver on Linux via cmd '%s'", cmd) res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False, - output_file=False, stream_output=False, split_stderr=True) + output_file=False, stream_output=False, split_stderr=True, env=environment) if res.exit_code == EasyBuildExit.SUCCESS: amd_driver = res.output.strip().split('\n')[1].split(',')[1] cmd = "rocm-smi --showproductname --csv" _log.debug("Trying to determine AMD GPU info on Linux via cmd '%s'", cmd) res = run_shell_cmd(cmd, fail_on_error=False, in_dry_run=True, hidden=True, with_hooks=False, - output_file=False, stream_output=False, split_stderr=True) + output_file=False, stream_output=False, split_stderr=True, env=environment) if res.exit_code == EasyBuildExit.SUCCESS: for line in res.output.strip().split('\n')[1:]: amd_card_series = line.split(',')[1] diff --git a/easybuild/tools/testing.py b/easybuild/tools/testing.py index f9ffaec8ee..2e95a5d025 100644 --- a/easybuild/tools/testing.py +++ b/easybuild/tools/testing.py @@ -369,7 +369,7 @@ def post_pr_test_report(pr_nrs, repo_type, test_report, msg, init_session_state, system_info['cpu_model'] += " (%s)" % system_info['cpu_arch_name'] # add GPU info, if known - gpu_info = get_gpu_info() + gpu_info = get_gpu_info(init_session_state['environment']) gpu_str = "" if gpu_info: for vendor, vendor_gpu in gpu_info.items(): From 79e870f0f629da9b078a624148696822c54ecea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Andr=C3=A9=20Reuter?= Date: Fri, 9 Jan 2026 23:29:57 +0100 Subject: [PATCH 2/2] Clearly document the env behavior of `build_and_install_software` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan André Reuter --- easybuild/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/easybuild/main.py b/easybuild/main.py index 034a9e9dd2..a5f40dcd1e 100755 --- a/easybuild/main.py +++ b/easybuild/main.py @@ -155,6 +155,8 @@ def summary(ecs_with_res): def build_and_install_software(ecs, init_session_state, exit_on_failure=True, testing=False): """ Build and install software for all provided parsed easyconfig files. + The build environment is reset to the one passed by init_session_state between builds. + However, the environment is _not_ reset after the last build. :param ecs: easyconfig files to install software with :param init_session_state: initial session state, to use in test reports