Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

fix: add exception handling to get amd gpu usage #405

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pyra/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -151,7 +151,10 @@
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

Check warning on line 157 in pyra/hardware.py

View check run for this annotation

Codecov / codecov/patch

pyra/hardware.py#L154-L157

Added lines #L154 - L157 were not covered by tests

if initialized and name:
try:
Expand Down
Loading