diff --git a/src/amdgpu_stats/tui.py b/src/amdgpu_stats/tui.py index b5e1925..9eb517f 100644 --- a/src/amdgpu_stats/tui.py +++ b/src/amdgpu_stats/tui.py @@ -277,6 +277,7 @@ class PowerDisplay(Static): """A widget to display GPU power stats.""" watts = reactive({"limit": 0, + "limit_pct": 0, "average": 0, "capability": 0, "default": 0}) @@ -318,7 +319,7 @@ class PowerDisplay(Static): - Updates label values - Casting inputs to string to avoid type problems w/ int/None""" self.query_one("#pwr_avg_val", - Static).update(f"{watts['average']}W") + Static).update(f"{watts['limit_pct']}%, {watts['average']}W") self.query_one("#pwr_lim_val", Static).update(f"{watts['limit']}W") self.query_one("#pwr_def_val", diff --git a/src/amdgpu_stats/utils.py b/src/amdgpu_stats/utils.py index 767e994..01e680a 100644 --- a/src/amdgpu_stats/utils.py +++ b/src/amdgpu_stats/utils.py @@ -132,12 +132,17 @@ def get_power_stats(card: Optional[str] = None) -> dict: """ card = validate_card(card) hwmon_dir = AMDGPU_CARDS[card] - - return {"limit": read_stat(path.join(hwmon_dir, "power1_cap"), stat_type='power'), + _pwr = {"limit": read_stat(path.join(hwmon_dir, "power1_cap"), stat_type='power'), + "limit_pct": 0, "average": read_stat(path.join(hwmon_dir, "power1_average"), stat_type='power'), "capability": read_stat(path.join(hwmon_dir, "power1_cap_max"), stat_type='power'), "default": read_stat(path.join(hwmon_dir, "power1_cap_default"), stat_type='power')} + if _pwr['limit'] != 0: + _pwr['limit_pct'] = round((_pwr['average'] / _pwr['limit']) * 100, 1) + + return _pwr + def get_core_stats(card: Optional[str] = None) -> dict: """