move some in-script comments to TODO, +some hinting
This commit is contained in:
parent
635c6cece9
commit
c263a2cac3
2 changed files with 18 additions and 16 deletions
15
gpustats.py
15
gpustats.py
|
@ -11,6 +11,7 @@ import argparse
|
||||||
from os import path
|
from os import path
|
||||||
import glob
|
import glob
|
||||||
import sys
|
import sys
|
||||||
|
from typing import Tuple, Optional
|
||||||
|
|
||||||
# from textual import events
|
# from textual import events
|
||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
|
@ -21,7 +22,7 @@ from textual.widgets import Header, Footer, Static, TextLog, Label
|
||||||
from humanfriendly import format_size
|
from humanfriendly import format_size
|
||||||
|
|
||||||
|
|
||||||
def find_card():
|
def find_card() -> Optional[Tuple[Optional[str], Optional[str]]]:
|
||||||
"""searches contents of /sys/class/drm/card*/device/hwmon/hwmon*/name
|
"""searches contents of /sys/class/drm/card*/device/hwmon/hwmon*/name
|
||||||
|
|
||||||
looking for 'amdgpu' to find a card to monitor
|
looking for 'amdgpu' to find a card to monitor
|
||||||
|
@ -337,7 +338,7 @@ if __name__ == "__main__":
|
||||||
interval = p_args.interval
|
interval = p_args.interval
|
||||||
# CARD = args.card
|
# CARD = args.card
|
||||||
|
|
||||||
# detect AMD GPU, exit if unfound
|
# exit if AMDGPU not found, otherwise - proceed, assigning stat files
|
||||||
if CARD is None:
|
if CARD is None:
|
||||||
sys.exit('Could not find an AMD GPU, exiting.')
|
sys.exit('Could not find an AMD GPU, exiting.')
|
||||||
|
|
||||||
|
@ -355,14 +356,7 @@ if __name__ == "__main__":
|
||||||
'fan_rpm': path.join(hwmon_dir, "fan1_input"),
|
'fan_rpm': path.join(hwmon_dir, "fan1_input"),
|
||||||
'fan_rpm_target': path.join(hwmon_dir, "fan1_target"),
|
'fan_rpm_target': path.join(hwmon_dir, "fan1_target"),
|
||||||
}
|
}
|
||||||
# notes:
|
|
||||||
# assumptions are made that freq{1,2}_input files are sclk/mclk
|
|
||||||
# contents of files named freq{1,2}_label can determine this reliably
|
|
||||||
# similarly:
|
|
||||||
# 'in0_input' has a peer named 'in0_label'
|
|
||||||
# should contain 'vddgfx' to indicate core voltage
|
|
||||||
# TODO: implement ^
|
|
||||||
#
|
|
||||||
# determine temperature nodes, construct an empty dict to store them
|
# determine temperature nodes, construct an empty dict to store them
|
||||||
temp_files = {}
|
temp_files = {}
|
||||||
temp_node_labels = glob.glob(path.join(hwmon_dir, "temp*_label"))
|
temp_node_labels = glob.glob(path.join(hwmon_dir, "temp*_label"))
|
||||||
|
@ -377,5 +371,6 @@ if __name__ == "__main__":
|
||||||
# add the node name/type and the corresponding temp file to the dict
|
# add the node name/type and the corresponding temp file to the dict
|
||||||
temp_files[temp_node_name] = temp_node_value_file
|
temp_files[temp_node_name] = temp_node_value_file
|
||||||
|
|
||||||
|
# start the party, draw the app and start collecting metrics
|
||||||
app = GPUStats()
|
app = GPUStats()
|
||||||
app.run()
|
app.run()
|
||||||
|
|
17
todo.md
17
todo.md
|
@ -7,11 +7,18 @@
|
||||||
- a wrapper of `format_size` from `humanfriendly`
|
- a wrapper of `format_size` from `humanfriendly`
|
||||||
- _(currently)_ defaults to highest sensible unit, changing on scale.
|
- _(currently)_ defaults to highest sensible unit, changing on scale.
|
||||||
- often flipping between `500Mhz` / `2.6Ghz` where consistency may be preferred
|
- often flipping between `500Mhz` / `2.6Ghz` where consistency may be preferred
|
||||||
|
- address assumptions on some statistic files
|
||||||
- restore `argparse`
|
- Clocks:
|
||||||
- primarily: `--card` / `-c`, to skip `amdgpu` device detection
|
- core/memory assumed provided by `freq1_input` and `freq2_input` respectively
|
||||||
|
- nearby files named `freq*_label` can determine this reliably
|
||||||
|
- Voltage:
|
||||||
|
- similarly, `in0_input` is the assumed voltage file
|
||||||
|
- indicated by `in*_label` with `vddgfx` inside
|
||||||
|
- no accounting for other voltage files currently; `APUs` / other cards may show more
|
||||||
|
- `argparse` extensions
|
||||||
|
- restore `--card` / `-c` under `argparse`
|
||||||
|
- to skip `amdgpu` device detection
|
||||||
- will expect `cardN` or `renderANNN` from `/dev/dri/`
|
- will expect `cardN` or `renderANNN` from `/dev/dri/`
|
||||||
- provides the (AMD) GPU intended to be monitored
|
- provides the (AMD) GPU intended to be monitored
|
||||||
- secondarily:
|
- may require card/hwmon detection be separate tasks
|
||||||
- preferred unit for clocks
|
- preferred unit for clocks
|
||||||
- perhaps an update interval for the Textual stat-updating timers
|
|
||||||
|
|
Reference in a new issue