okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c97ad41eb
main
1"""Sample system RAM, swap and AMD GPU memory once per second during the trial. 2 3MI50 / ROCm adaptation: GPU memory via rocm-smi instead of nvidia-smi, and the 4GPU is the Vega 20 (MI50) at PCI 0000:07:00.0 — rocm-smi indexes it as GPU[0]. 5Runs on the HOST (needs rocm-smi), writes telemetry.jsonl. 6""" 7import json 8import subprocess 9import sys 10import time 11from pathlib import Path 12 13 14def gpu_mem (): 15try : 16out = subprocess .check_output ( 17 ["rocm-smi" ,"--showmeminfo" ,"vram" ,"--showuse" ,"--showtemp" ,"--csv" ], 18text = True ,stderr = subprocess .DEVNULL ).strip () 19return out 20except Exception as error :# noqa: BLE001 21return f"rocm-smi error: { error } " 22 23 24with Path (sys .argv [1 ]if len (sys .argv )> 1 else "telemetry.jsonl" ).open ("a" )as output : 25while True : 26memory = {} 27for line in Path ("/proc/meminfo" ).read_text ().splitlines (): 28key ,value = line .split (":" ,1 ) 29if key in ("MemTotal" ,"MemAvailable" ,"SwapTotal" ,"SwapFree" ): 30memory [key + "_KiB" ]= int (value .strip ().split ()[0 ]) 31output .write (json .dumps ({"epoch_s" :time .time (),"memory" :memory ,"gpu" :gpu_mem ()})+ "\n" ) 32output .flush () 33time .sleep (1 )