okami.mom/strata

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

Niko1221Merge f-029-par-harness1fb3e9a32

main
1.8 KiB31 linesraw
1#!/usr/bin/env python3
2"""e00.py OUT.json [CUDA_HOME] - machine capability JSON: nvidia-smi links, e00_probe.cu results, RAM, NUMA, CPU (read-only)."""
3import json, os, platform, subprocess, sys, tempfile
4
5out = sys.argv[1]
6ch = sys.argv[2] if len(sys.argv) > 2 else "/usr/local/cuda"
7here = os.path.dirname(os.path.abspath(__file__))
8w = tempfile.mkdtemp()
9
10
11def sh(c, t=120):
12    try:
13        return subprocess.run(c, shell=True, capture_output=True, text=True, timeout=t).stdout.strip()
14    except Exception as e:  # noqa: BLE001
15        return str(e)
16
17
18subprocess.run([f"{ch}/bin/nvcc", "-O2", "-std=c++17", f"{here}/e00_probe.cu", "-o", f"{w}/p", "-lpthread"], check=True)
19p = json.loads(sh(f"{w}/p", 300))
20p["host"] = platform.node()
21p["nvidia_smi_pcie"] = sh("nvidia-smi --query-gpu=index,name,pci.bus_id,pcie.link.gen.current,pcie.link.gen.max,pcie.link.width.current,pcie.link.width.max,power.limit,clocks.max.sm,display_active,memory.total,memory.used,driver_version --format=csv").splitlines()
22p["nvidia_topo"] = sh("nvidia-smi topo -m").splitlines()
23want = ("Model name", "Socket(s)", "Core(s) per socket", "Thread(s) per core", "NUMA node(s)", "L3 cache")
24p["lscpu"] = {l.split(":", 1)[0].strip(): l.split(":", 1)[1].strip() for l in sh("lscpu").splitlines() if ":" in l and l.split(":", 1)[0].strip() in want}
25p["meminfo_gb"] = {l.split(":")[0]: int(l.split()[1]) // 1048576 for l in open("/proc/meminfo") if l.split(":")[0] in ("MemTotal", "MemAvailable", "SwapTotal")}
26p["dimms"] = sh("sudo -n dmidecode -t memory 2>/dev/null | grep -E 'Speed:|Size: [0-9]' | sort | uniq -c").splitlines()
27p["numa"] = sh("numactl -H 2>/dev/null | head -8").splitlines()
28p["kernel"] = platform.release()
29p["note"] = "read-only probe; IOMMU/ACS/clocks untouched"
30json.dump(p, open(out, "w"), indent=1)
31print("wrote", out)