okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

GPFbench: community report, RX 6700 XT 12 GB (gfx1031), Ryzen 7 5700G, I… (#1027)cfb4a3349

main
1.4 KiB34 linesraw
1"""Sample system RAM, swap and the AMD GPU's memory, load, power and temperature once per second (sysfs).
2The RTX 5090 report's monitor.py calls nvidia-smi; this reads the same quantities from amdgpu's sysfs files."""
3import glob
4import json
5import sys
6import time
7from pathlib import Path
8
9CARD = Path(sys.argv[2] if len(sys.argv) > 2 else '/sys/class/drm/card1/device')
10HWMON = Path(glob.glob(str(CARD / 'hwmon' / 'hwmon*'))[0])
11
12
13def number(path):
14    try:
15        return int(Path(path).read_text().strip())
16    except (OSError, ValueError):
17        return None
18
19
20with Path(sys.argv[1] if len(sys.argv) > 1 else 'telemetry.jsonl').open('a') as output:
21    while True:
22        memory = {}
23        for line in Path('/proc/meminfo').read_text().splitlines():
24            key, value = line.split(':', 1)
25            if key in ('MemTotal', 'MemAvailable', 'SwapTotal', 'SwapFree'):
26                memory[key + '_KiB'] = int(value.strip().split()[0])
27        gpu = {'vram_used_bytes': number(CARD / 'mem_info_vram_used'),
28               'vram_total_bytes': number(CARD / 'mem_info_vram_total'),
29               'gpu_busy_percent': number(CARD / 'gpu_busy_percent'),
30               'power_average_uW': number(HWMON / 'power1_average'),
31               'temperature_mC': number(HWMON / 'temp1_input')}
32        output.write(json.dumps({'epoch_s': time.time(), 'memory': memory, 'gpu': gpu}) + '\n')
33        output.flush()
34        time.sleep(1)