Web UI¶
xpustat --ui serves a browser page that shows every device the CLI knows about, for this machine or for a whole cluster, with no dependency beyond the standard library. The page is one HTML file with its CSS and JavaScript inline; it loads nothing from the network, so it works on air-gapped nodes.
Running it¶
xpustat --ui # http://127.0.0.1:9400/
xpustat --ui --cpu -i 2 --port 8080 # with the CPU row, refreshed every 2 s, on port 8080
xpustat --ui --host 0.0.0.0 # reachable from other machines
The same server also answers /json (this machine's device JSON with metadata), /metrics (Prometheus text), /cluster (what the page reads), /history (the per-device series behind the sparklines), /alerts (the active alerts) and /free (the freest devices), so one process serves the browser, scripts and Prometheus.
The UI binds to 127.0.0.1 by default because the page shows process owners and command lines. Use --host 0.0.0.0 to expose it, or reach a remote machine's page through an ssh tunnel:
ssh -L 9400:127.0.0.1:9400 node1 'xpustat --ui --cpu'
# then open http://127.0.0.1:9400/ locally
Many machines on one page¶
xpustat --ui --ssh node1 node2 node3 --cpu -i 5 # xpustat installed on each node
xpustat --ui --hosts http://node4:9400 http://node5:9400 # nodes running --serve-prometheus or --ui
xpustat --ui --hosts-file lab.txt # one host per line, # comments
xpustat --ui --ssh node1 --ssh-command '~/.local/bin/xpustat --json --cpu'
xpustat --ui --ssh node1 node2 --no-local # leave this machine out
--ssh, --hosts, --hosts-file, --ssh-command and --timeout work as for the terminal cluster view. A hosts file may mix exporter URLs (http://... or host:port) and ssh hosts (node, user@node). This machine is the first host on the page unless --no-local is given.
One ssh session per host¶
For each ssh host the server keeps one session running xpustat --json --meta -i N on the remote and reads one JSON line per refresh, so forty nodes cost forty connections once, not forty connections every five seconds. The block header shows streaming when that is the mode. A remote older than 0.7.0 does not know --meta; the server notices and polls it with a command per refresh instead, and --no-stream forces that for every host. --ssh-command always polls, since a custom command cannot be assumed to stream. Connections are multiplexed (ControlMaster) on Linux and macOS; XPUSTAT_SSH_OPTS adds ssh options and XPUSTAT_SSH_NO_MULTIPLEX=1 turns multiplexing off. The default command puts ~/.local/bin on the PATH, so an xpustat installed with uv tool or pipx is found by a non-interactive shell.
Every open browser tab reads the server's cached answer. A host that stops answering keeps its last good snapshot on the page, marked stale with the error; a host that never answered is shown as unreachable; a host running an older xpustat than the server gets an older xpustat badge. The other hosts are unaffected.
History¶
The server keeps --history worth of samples per device (default 15m; 30m, 2h, 1d) and the page seeds its sparklines from them, so a reload or a second tab shows the same curves. --history-file FILE.sqlite also appends every frame to a SQLite file, which xpustat --replay FILE.sqlite plays back host by host. Memory: one sample per device per refresh, about 60 KB per device for an hour at a 5 s refresh.
Alerts¶
The server evaluates every refresh: a device at or over --max-temp (default 85 °C), uncorrected ECC errors, a throttled device (unless --no-alert-throttle), an unhealthy device, less than --min-free MB free, a host down or stale. The page shows them in a bar under the header; the notify button asks the browser for permission and then raises a desktop notification for each new critical alert. --alert-url URL POSTs new alerts as JSON to a webhook with a cooldown; see Deployment. The same thresholds drive xpustat --check.
One scrape for the cluster¶
With remote hosts configured, /metrics exports every host with a host label, plus xpustat_host_up and xpustat_host_stale, so Prometheus scrapes one target for the lab. /json keeps describing this machine. /free?n=2&vendor=nvidia&min_free=4000 returns the freest devices across the reachable hosts, the same ranking as xpustat --select 2 --ssh ....
What the page shows¶
The summary bar across all hosts: hosts up and down, devices and how many are free (under 5 % memory used, under 5 % utilization, no processes), device memory used over total (the CPU row is left out of this sum), processes, the hottest device, and how many devices are throttled or report a fault.
Then one block per host with a table of its devices. The columns are the -a set of the CLI: vendor tag and index, name with the architecture (cuda_cc, gfx_target, Apple GPU cores), memory bar with used and total, utilization, temperature (orange from 70 °C, red from 85 °C), power with its limit, fan, SM or graphics clock with its maximum and the memory clock, P-state or performance level, health (ok, fault, throttled, ECC n), process count, and two sparklines of utilization and memory for the time the tab has been open. MIG instances are listed under their parent GPU.
Clicking a device row opens its detail: UUID, free memory, memory utilization, hotspot and memory temperatures, encoder and decoder load, ECC counts, throttle reasons, energy, PCIe link, ANE power on Apple, and the processes with PID, user, device memory, SM share, host RSS, CPU share, container or SLURM job, and the full command line. For the CPU row the detail holds cores, sockets, core layout, load average, frequency, swap, NUMA nodes, cgroup limits and per-core utilization.
Controls in the header: a host filter, a vendor filter, a user filter (devices with a process of that user, across hosts: "where are my jobs"), a text filter over device names, users, commands, containers and PIDs, a compact mode that hides the fan, clock, state and sparkline columns so forty devices fit on one screen, expand all, a CSV download of the rows shown, notifications, and pause. Opening /?expand starts with every row expanded. The compact setting is remembered in the browser. Columns have fixed widths, so the tables of different hosts line up.
From Python¶
from xpustat.ui import ClusterCollector, serve_ui
serve_ui(port=9400, host="127.0.0.1") # local page; blocks
collector = ClusterCollector(ssh=["node1", "node2"], include_cpu=True, interval=5)
serve_ui(port=9400, cluster=collector) # cluster page; starts the poller
serve_ui takes a query callable like xpustat.prometheus.serve. ClusterCollector(fetch=...) accepts a callable returning RemoteHost objects for a custom source, local= a callable for this machine, history=xpustat.History(window=3600, path=...), thresholds=xpustat.Thresholds(...) and notifier=xpustat.alerts.Notifier(url); snapshot() returns the /cluster payload and hosts() the host list for xpustat.pick_remote and xpustat.to_prometheus_hosts.
Limitations¶
- No authentication and no TLS: keep it on
127.0.0.1, behind an ssh tunnel or a reverse proxy. - History is bounded by
--historyand lives in the server's memory, or in the--history-file; use the Prometheus exporter for long retention. /jsonalways describes the local machine;/metricscovers every host once remote hosts are configured.- A remote older than 0.7.0 carries no hostname or query time (no
--meta), so the page labels it by its ssh name.