diff --git a/library/sensors/sensors_python.py b/library/sensors/sensors_python.py index 2ec10cb1..cbbb90c0 100644 --- a/library/sensors/sensors_python.py +++ b/library/sensors/sensors_python.py @@ -275,52 +275,42 @@ class GpuAmd(sensors.Gpu): def stats() -> Tuple[float, float, float, float]: # load (%) / used mem (%) / used mem (Mb) / temp (°C) if pyamdgpuinfo: # Unlike other sensors, AMD GPU with pyamdgpuinfo pulls in all the stats at once - i = 0 - amd_gpus = [] - while i < pyamdgpuinfo.detect_gpus(): - amd_gpus.append(pyamdgpuinfo.get_gpu(i)) - i = i + 1 + amd_gpu = pyamdgpuinfo.get_gpu(0) try: - memory_used_all = [item.query_vram_usage() for item in amd_gpus] - memory_used_bytes = sum(memory_used_all) / len(memory_used_all) + memory_used_bytes = amd_gpu.query_vram_usage() memory_used = memory_used_bytes / 1000000 except: memory_used_bytes = math.nan memory_used = math.nan try: - memory_total_all = [item.memory_info["vram_size"] for item in amd_gpus] - memory_total_bytes = sum(memory_total_all) / len(memory_total_all) + memory_total_bytes = amd_gpu.memory_info["vram_size"] memory_percentage = (memory_used_bytes / memory_total_bytes) * 100 except: memory_percentage = math.nan try: - load_all = [item.query_load() for item in amd_gpus] - load = (sum(load_all) / len(load_all)) * 100 + load = amd_gpu.query_load() except: load = math.nan try: - temperature_all = [item.query_temperature() for item in amd_gpus] - temperature = sum(temperature_all) / len(temperature_all) + temperature = amd_gpu.query_temperature() except: temperature = math.nan return load, memory_percentage, memory_used, temperature elif pyadl: - amd_gpus = pyadl.ADLManager.getInstance().getDevices() + amd_gpu = pyadl.ADLManager.getInstance().getDevices()[0] try: - load_all = [item.getCurrentUsage() for item in amd_gpus] - load = (sum(load_all) / len(load_all)) + load = amd_gpu.getCurrentUsage() except: load = math.nan try: - temperature_all = [item.getCurrentTemperature() for item in amd_gpus] - temperature = sum(temperature_all) / len(temperature_all) + temperature = amd_gpu.getCurrentTemperature() except: temperature = math.nan @@ -348,8 +338,10 @@ def fan_percent() -> float: @staticmethod def frequency() -> float: - # Not supported by Python libraries - return math.nan + if pyamdgpuinfo: + return pyamdgpuinfo.get_gpu(0).query_sclk() + elif pyadl: + return pyadl.ADLManager.getInstance().getDevices()[0].getCurrentEngineClock() @staticmethod def is_available() -> bool: