From 7715f942708287f3d3c7dcbaf0a48c2a0b4ad01c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 18 Jan 2024 20:33:24 -0500 Subject: [PATCH] fix: add exception handling to get amd gpu usage (#405) --- pyra/hardware.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyra/hardware.py b/pyra/hardware.py index 9018f4d57..44b885d78 100644 --- a/pyra/hardware.py +++ b/pyra/hardware.py @@ -64,7 +64,7 @@ except ModuleNotFoundError: pyamdgpu = False try: - from pyadl import ADLManager + from pyadl import ADLManager, ADLError except Exception: # cannot import `ADLError` from `pyadl.pyadl` amd_gpus = range(0) # no amd gpus found else: @@ -151,7 +151,10 @@ def update_gpu(): gpu_load = min(100, gpu.query_load()) # max of 100 else: name = f'{gpu.adapterName.decode("utf-8")}-{gpu.adapterIndex}' # adapterName is bytes so decode it - gpu_load = min(100, gpu.getCurrentUsage()) # max of 100 + try: + gpu_load = min(100, gpu.getCurrentUsage()) # max of 100 + except ADLError: + gpu_load = None if initialized and name: try: