power: report usage as a percentage of limit
This commit is contained in:
parent
6a7964285e
commit
f323e4defe
2 changed files with 9 additions and 3 deletions
|
@ -277,6 +277,7 @@ class PowerDisplay(Static):
|
||||||
"""A widget to display GPU power stats."""
|
"""A widget to display GPU power stats."""
|
||||||
|
|
||||||
watts = reactive({"limit": 0,
|
watts = reactive({"limit": 0,
|
||||||
|
"limit_pct": 0,
|
||||||
"average": 0,
|
"average": 0,
|
||||||
"capability": 0,
|
"capability": 0,
|
||||||
"default": 0})
|
"default": 0})
|
||||||
|
@ -318,7 +319,7 @@ class PowerDisplay(Static):
|
||||||
- Updates label values
|
- Updates label values
|
||||||
- Casting inputs to string to avoid type problems w/ int/None"""
|
- Casting inputs to string to avoid type problems w/ int/None"""
|
||||||
self.query_one("#pwr_avg_val",
|
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",
|
self.query_one("#pwr_lim_val",
|
||||||
Static).update(f"{watts['limit']}W")
|
Static).update(f"{watts['limit']}W")
|
||||||
self.query_one("#pwr_def_val",
|
self.query_one("#pwr_def_val",
|
||||||
|
|
|
@ -132,12 +132,17 @@ def get_power_stats(card: Optional[str] = None) -> dict:
|
||||||
"""
|
"""
|
||||||
card = validate_card(card)
|
card = validate_card(card)
|
||||||
hwmon_dir = AMDGPU_CARDS[card]
|
hwmon_dir = AMDGPU_CARDS[card]
|
||||||
|
_pwr = {"limit": read_stat(path.join(hwmon_dir, "power1_cap"), stat_type='power'),
|
||||||
return {"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'),
|
"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'),
|
"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')}
|
"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:
|
def get_core_stats(card: Optional[str] = None) -> dict:
|
||||||
"""
|
"""
|
||||||
|
|
Reference in a new issue