macpm 2.2__tar.gz → 3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. macpm-3.0/CHANGELOG.md +229 -0
  2. {macpm-2.2 → macpm-3.0}/MANIFEST.in +1 -0
  3. {macpm-2.2/macpm.egg-info → macpm-3.0}/PKG-INFO +241 -11
  4. macpm-3.0/README.md +558 -0
  5. {macpm-2.2 → macpm-3.0}/RELEASE.md +14 -12
  6. macpm-3.0/docs/linux-port.md +241 -0
  7. {macpm-2.2 → macpm-3.0}/macpm/__init__.py +1 -1
  8. macpm-3.0/macpm/backend.py +145 -0
  9. macpm-3.0/macpm/capabilities.py +62 -0
  10. macpm-3.0/macpm/dump.py +81 -0
  11. macpm-3.0/macpm/gpuview.py +796 -0
  12. macpm-3.0/macpm/linux_backend/__init__.py +37 -0
  13. macpm-3.0/macpm/linux_backend/cpu.py +321 -0
  14. macpm-3.0/macpm/linux_backend/gpu.py +1411 -0
  15. macpm-3.0/macpm/linux_backend/modelname.py +145 -0
  16. macpm-3.0/macpm/linux_backend/net.py +319 -0
  17. macpm-3.0/macpm/linux_backend/power.py +195 -0
  18. macpm-3.0/macpm/linux_backend/proc.py +145 -0
  19. macpm-3.0/macpm/linux_backend/sampler.py +289 -0
  20. macpm-3.0/macpm/linux_backend/soc.py +113 -0
  21. macpm-3.0/macpm/linux_backend/sysfs.py +124 -0
  22. macpm-3.0/macpm/linux_backend/thermal.py +212 -0
  23. macpm-3.0/macpm/macos_gpu.py +184 -0
  24. {macpm-2.2 → macpm-3.0}/macpm/macpm.py +437 -324
  25. macpm-3.0/macpm/metrics.py +103 -0
  26. {macpm-2.2 → macpm-3.0}/macpm/netinfo.py +88 -13
  27. macpm-3.0/macpm/netmodel.py +110 -0
  28. {macpm-2.2 → macpm-3.0}/macpm/network.py +26 -108
  29. macpm-3.0/macpm/probe.py +409 -0
  30. {macpm-2.2 → macpm-3.0}/macpm/processes.py +53 -162
  31. {macpm-2.2 → macpm-3.0}/macpm/sampler.py +28 -81
  32. {macpm-2.2 → macpm-3.0}/macpm/sensors.py +101 -28
  33. {macpm-2.2 → macpm-3.0}/macpm/smc.py +38 -23
  34. {macpm-2.2 → macpm-3.0}/macpm/tui.py +12 -0
  35. {macpm-2.2 → macpm-3.0/macpm.egg-info}/PKG-INFO +241 -11
  36. macpm-3.0/macpm.egg-info/SOURCES.txt +77 -0
  37. {macpm-2.2 → macpm-3.0}/packaging/README.txt +1 -1
  38. {macpm-2.2 → macpm-3.0}/packaging/build.sh +2 -2
  39. macpm-3.0/packaging/linux/Dockerfile +32 -0
  40. macpm-3.0/packaging/linux/README.txt +50 -0
  41. {macpm-2.2 → macpm-3.0}/setup.py +4 -3
  42. macpm-3.0/tests/linux_fixtures.py +258 -0
  43. {macpm-2.2 → macpm-3.0}/tests/test_cli.py +1 -1
  44. macpm-3.0/tests/test_gpuview.py +391 -0
  45. macpm-3.0/tests/test_linux_cpu.py +130 -0
  46. macpm-3.0/tests/test_linux_gpu.py +284 -0
  47. macpm-3.0/tests/test_linux_ixsmi.py +334 -0
  48. macpm-3.0/tests/test_linux_modelname.py +113 -0
  49. macpm-3.0/tests/test_linux_net.py +149 -0
  50. macpm-3.0/tests/test_linux_nvidia.py +155 -0
  51. macpm-3.0/tests/test_linux_power.py +132 -0
  52. macpm-3.0/tests/test_linux_sampler.py +327 -0
  53. macpm-3.0/tests/test_linux_thermal.py +108 -0
  54. macpm-3.0/tests/test_linux_view.py +285 -0
  55. macpm-3.0/tests/test_linux_wiring.py +114 -0
  56. macpm-3.0/tests/test_probe.py +66 -0
  57. macpm-3.0/tests/test_sampler_macos.py +80 -0
  58. {macpm-2.2 → macpm-3.0}/tests/test_sensors.py +1 -1
  59. macpm-2.2/CHANGELOG.md +0 -123
  60. macpm-2.2/README.md +0 -329
  61. macpm-2.2/macpm/dump.py +0 -21
  62. macpm-2.2/macpm.egg-info/SOURCES.txt +0 -41
  63. {macpm-2.2 → macpm-3.0}/LICENSE +0 -0
  64. {macpm-2.2 → macpm-3.0}/macpm/__main__.py +0 -0
  65. {macpm-2.2 → macpm-3.0}/macpm/ioreport.py +0 -0
  66. {macpm-2.2 → macpm-3.0}/macpm/soc.py +0 -0
  67. {macpm-2.2 → macpm-3.0}/macpm.egg-info/dependency_links.txt +0 -0
  68. {macpm-2.2 → macpm-3.0}/macpm.egg-info/entry_points.txt +0 -0
  69. {macpm-2.2 → macpm-3.0}/macpm.egg-info/not-zip-safe +0 -0
  70. {macpm-2.2 → macpm-3.0}/macpm.egg-info/requires.txt +0 -0
  71. {macpm-2.2 → macpm-3.0}/macpm.egg-info/top_level.txt +0 -0
  72. {macpm-2.2 → macpm-3.0}/packaging/entry_tui.py +0 -0
  73. {macpm-2.2 → macpm-3.0}/packaging/install.sh +0 -0
  74. {macpm-2.2 → macpm-3.0}/packaging/macpm.command +0 -0
  75. {macpm-2.2 → macpm-3.0}/pyproject.toml +0 -0
  76. {macpm-2.2 → macpm-3.0}/setup.cfg +0 -0
  77. {macpm-2.2 → macpm-3.0}/tests/__init__.py +0 -0
  78. {macpm-2.2 → macpm-3.0}/tests/test_calc_freq.py +0 -0
  79. {macpm-2.2 → macpm-3.0}/tests/test_layout.py +0 -0
  80. {macpm-2.2 → macpm-3.0}/tests/test_netinfo.py +0 -0
  81. {macpm-2.2 → macpm-3.0}/tests/test_network.py +0 -0
  82. {macpm-2.2 → macpm-3.0}/tests/test_processes.py +0 -0
  83. {macpm-2.2 → macpm-3.0}/tests/test_sampler.py +0 -0
macpm-3.0/CHANGELOG.md ADDED
@@ -0,0 +1,229 @@
1
+ # Changelog
2
+
3
+ ## 3.0 — 2026-11-14
4
+
5
+ The Linux release. The same package and the same TUI now run on x86_64 and
6
+ arm64 Linux, and the GPU view grew into a per-card monitor that scales from one
7
+ Apple GPU to a 64-card accelerator server. Verified on 16× Iluvatar BI-V150S,
8
+ 64× Denglin KS58, 8× Techo TECO_AICARD_01 and 8× RTX 4090.
9
+
10
+ ### Added
11
+
12
+ - **Linux backend** (`macpm/backend.py`, `macpm/linux_backend/`): the platform
13
+ is chosen at runtime, and every reading is normalised into the powermetrics
14
+ shaped sample the UI already understood, so all four views and key bindings
15
+ are unchanged.
16
+ - CPU: per-core utilisation from `/proc/stat`, frequency from
17
+ `cpufreq/scaling_cur_freq` (residency-weighted when
18
+ `cpu/stats/time_in_state` exists), and an E/P split inferred from
19
+ `topology/core_type`, `cpu_capacity` or `cpuinfo_max_freq`.
20
+ - Power: RAPL `energy_uj` (root on kernels >= 5.10), GPU hwmon power and the
21
+ battery's `power_now` as a whole-system fallback.
22
+ - GPU: amdgpu (`gpu_busy_percent`, `pp_dpm_sclk`, hwmon), Intel i915/xe
23
+ (frequency plus aggregate DRM `fdinfo` engine time) and NVIDIA via
24
+ `nvidia-smi`.
25
+ - Thermals: hwmon temperatures/fans classified by chip name and label, plus
26
+ a PSI/x86-throttle approximation of the thermal state.
27
+ - Process view: per-process GPU time from `drm-engine-*` `fdinfo`; Linux lets
28
+ `psutil` read every user's CPU/memory as root.
29
+ - Network view: `/proc/net/{tcp,tcp6,udp,udp6}` for counts and listeners and
30
+ `ss -tanie` `tcp_info` joined by inode for the per-process traffic table
31
+ (TCP only).
32
+ - Capabilities say what the kernel and permission level actually expose;
33
+ everything else is shown as `n/a` instead of a fake zero, and the UI hides
34
+ panels it cannot fill.
35
+ - **GPU view** on key `5` — one table with **two lines per card**: the metrics
36
+ line (utilisation bar, clock, power, a 10-cell VRAM bar, temperature) and the
37
+ processes on that card (`PID NAME [cards] GPU% MEM`), with the served model
38
+ name right-aligned. A process holding several cards appears under each of
39
+ them with its range in brackets; a card with more processes than fit shows
40
+ `… +N`. `s` cycles the in-card order (PID → NAME → MEM), `↑` / `↓` turn
41
+ whole pages and the footer shows `Page N/M`. A single-GPU machine keeps the
42
+ card summary and the separate process table.
43
+ - **GPU INFO box** above the table: vendor card name, device count, card count
44
+ and dies per card (devices ÷ unique serials), driver, CUDA, PCIe link
45
+ (maximum, so idle cards do not read as generation 1) and VBIOS — each hidden
46
+ when the tool does not report it. Consumer cards that report `[N/A]` serials
47
+ leave the card/die counts out instead of guessing.
48
+ - **Vendor accelerator backends** — cards with no DRM counters are read through
49
+ the vendor's NVML-style CLI: `ixsmi` (Iluvatar / 天数, `--query-gpu`),
50
+ `dlsmi` (Denglin / 登临, `--query-gpu`) and `teco-smi` (Techo / 太初,
51
+ `--query-device`). Each tool's switch and property names are mapped onto the
52
+ same fields, the power property is negotiated per tool, and the binaries are
53
+ found on `PATH`, in their install directories or via `MACPM_IXSMI`,
54
+ `MACPM_DLSMI` and `MACPM_TECO`.
55
+ - **Vendor compute processes** feed the GPU view: `ixsmi pmon` joined with
56
+ `--query-compute-apps` (memory), `dlsmi --query-compute-apps` and
57
+ `teco-smi pmon`. One row per PID with the cards it holds (compressed to
58
+ `0-7`), its card memory and the vendor's GPU% where the tool reports one
59
+ (`—` otherwise, e.g. `dlsmi`). Processes that hold several cards are listed
60
+ under each of them, and `teco-smi`'s per-device repetition is preserved
61
+ rather than pretending a process lives on one card.
62
+ - **Served model name** on the process line, right-aligned: resolved from the
63
+ launcher's command line (`--served-model-name`, `--model`, `--model-path`,
64
+ `--model-id`, `vllm serve`, `sglang.launch_server`, TGI, llama.cpp, including
65
+ k8s `bash -c` wrappers) by walking the parent chain, cached for ten seconds.
66
+ Only procfs is read; model directories are never opened because a stalled
67
+ network mount can block that indefinitely.
68
+ - **NVIDIA GPU view** — one `nvidia-smi --query-gpu` call for the card rows,
69
+ `--query-compute-apps` (joined with `pmon` for SM%) for the process lines and
70
+ the same tool for the INFO box. `nvidia-smi` is resolved from
71
+ `MACPM_NVIDIA_SMI`, `PATH` or the WSL mount, and NVIDIA DRM nodes are skipped
72
+ when `nvidia-smi` is available so cards are not listed twice.
73
+ - **`python3 -m macpm.probe`** — a standard-library inventory (cards, drivers,
74
+ vendor tools, capability report) for compute nodes, with no psutil or
75
+ terminal needed. `macpm-dump --capabilities` prints the platform, root
76
+ state and the same report.
77
+ - **Deterministic tests on any machine** — `MACPM_SYSROOT` replays a captured
78
+ `/proc` + `/sys` tree, `MACPM_PLATFORM` forces the Linux backend, and
79
+ `tests/linux_fixtures.py` builds hybrid x86, arm64 big.LITTLE, multi-card and
80
+ empty trees.
81
+ - Every view's footer starts with the app name and version
82
+ (`macpm v3.0 · q quit …`), so a screenshot or pasted frame identifies the
83
+ build.
84
+
85
+ ### Changed
86
+
87
+ - CoreFoundation/IOKit/IOReport/AppleSMC are loaded lazily, so importing macpm
88
+ (and `--version` / `--help`) works on platforms without those frameworks.
89
+ - The UI builds its gauges from the detected capabilities: no E cluster means a
90
+ single `CPU Usage` gauge, no ANE means no ANE gauge, no GPU means no GPU
91
+ gauge, and the power panel is hidden when no power source exists.
92
+ - The default route and public-IP lookup use `urllib` instead of `curl`, and
93
+ `ip route` / `/proc/net/route` instead of `route -n get default` on Linux.
94
+ - The sensor panel says `sensors unavailable` instead of `SMC unavailable`
95
+ (the backend may be hwmon).
96
+
97
+ ### Fixed
98
+
99
+ - NVIDIA GPUs were listed twice on drivers that expose DRM nodes (16 rows for
100
+ 8 cards); the DRM duplicate is skipped when `nvidia-smi` is present.
101
+ - Drivers that reject `cuda_version` (e.g. 580) made the whole INFO query fail;
102
+ the query now falls back to the remaining fields.
103
+ - `teco-smi` cards/dies are no longer derived from serials: it exposes eight
104
+ cards of four SDAA dies each without a board grouping, so only the device
105
+ count is shown.
106
+ - VRAM cells pad the used-memory number to a fixed width, so busy and idle
107
+ cards keep their bars aligned.
108
+
109
+ ## 2.2 — 2026-11-12
110
+
111
+ ### Added
112
+
113
+ - **Network view** on key `4` — a rootless overview built from `nettop`: TCP
114
+ socket counts by state (`ESTABLISHED`, `LISTEN`, `CLOSE_WAIT`, `TIME_WAIT`),
115
+ UDP socket count, interface throughput, a listening table (address, PID,
116
+ process) and a per-process traffic table with socket count and download /
117
+ upload rates. `Tab` switches the focused table, `s` cycles its sort column,
118
+ `↑` / `↓` scroll it and `Space` pauses sampling. The traffic table
119
+ refreshes every 2 seconds and the full socket snapshot every 5 seconds while
120
+ the view is open. `nettop` needs no root and sees sockets owned by root
121
+ daemons; sockets without an owner (typically `TIME_WAIT`) are not reported.
122
+ - The network summary box has a line with the active IPv4 interface and prefix,
123
+ the default gateway, and the public IP with its city. For Chinese addresses
124
+ the carrier abbreviation (Telecom, Unicom, Mobile) is appended after the
125
+ country code, e.g. `Shanghai, CN Telecom`.
126
+ The public lookup is one HTTPS request to `ipinfo.io` (falling back to
127
+ `ipwho.is`), cached for 10 minutes and disabled with `--no-public-ip`.
128
+
129
+ ### Changed
130
+
131
+ - The network summary uses fixed-width fields, so the labels no longer move as
132
+ the counter and rate values change. The traffic table is sorted by the
133
+ visible `↓/s` column by default; the combined rate is no longer a hidden sort
134
+ key.
135
+ - The Temps & Fans panel now pairs each component's temperature with its peak
136
+ (CPU on one row, GPU on the next), followed by fan RPMs and one fan-load bar
137
+ per fan. The bars omit the numeric percentage so they can use the full panel
138
+ width. The network identity line is only shown in view 1, not in the
139
+ per-core view.
140
+ - README: screenshots for the process and network views and refreshed
141
+ highlights.
142
+
143
+ ### Fixed
144
+
145
+ - Arrow keys were delivered as a bare `ESC` — which quits macpm — because the
146
+ curses window never enabled keypad mode. `↑` / `↓` now scroll the process
147
+ and network tables as documented.
148
+ - The views reset only the foreground colour after drawing, not the whole SGR
149
+ state. A full reset also cleared the black background set by curses, so the
150
+ terminal profile's background (often grey) showed through in the default,
151
+ process and network views.
152
+
153
+ ## 2.1 — 2026-11-11
154
+
155
+ ### Changed
156
+
157
+ - The power panel is titled `Power` instead of `CPU+GPU+ANE Power`, and every
158
+ panel title is clipped to its box so a long title never wraps the frame.
159
+ - The Temps & Fans panel now uses its spare rows for CPU/GPU peak temperatures
160
+ and fan limits instead of leaving them blank.
161
+ - Per-core gauges are labelled `E1…` / `P1…` instead of `Core-1` / `C-1`, so
162
+ narrow gauges keep the percentage readable.
163
+
164
+ ### Added
165
+
166
+ - **Temps & Fans panel** in the default view — hottest CPU and GPU sensor in
167
+ °C and the current RPM of every fan, read from `AppleSMC` without root.
168
+ - **Process view** on key `3` — a two-box layout: a
169
+ CPU/GPU/RAM summary box (with wired/active/inactive/free memory) and a
170
+ process table with PID, NAME, USER, CPU%, MEM and GPU% columns, sorted with
171
+ `s`, scrolled with `↑`/`↓` and paused with `Space`. The table refreshes
172
+ every 2 seconds to keep macpm's own CPU low. There is no power column.
173
+
174
+ ### Removed
175
+
176
+ - The separate `macpm-sensors` command. The SMC reader is now part of the TUI
177
+ (`macpm.sensors.SensorReader`).
178
+
179
+ ### Fixed
180
+
181
+ - Impossible power peaks (such as `peak: 6208.38W`) caused by coalesced or
182
+ reset Energy Model counters are now discarded instead of being recorded.
183
+ - When the unprivileged Energy Model counters never report, the power panel
184
+ shows `n/a` instead of a misleading `0.00W`; the total is withheld only when
185
+ both CPU and GPU are unreadable.
186
+
187
+ ## 2.0 — 2026-11-10
188
+
189
+ ### Changed
190
+
191
+ - **Rootless by default**: macpm no longer runs `sudo`, `powermetrics` or any
192
+ privileged helper. Data is collected from IOReport, IOKit, `psutil`,
193
+ `sysctl`, `ioreg` and `pmset`.
194
+ - Reworked the sampler into `macpm.sampler`, with ctypes bindings in
195
+ `macpm.ioreport` and SoC/DVFS discovery in `macpm.soc`.
196
+ - The terminal layout, panel titles, charts, colours and key bindings remain
197
+ the same as macpm 0.x.
198
+ - Version bumped to 2.0.
199
+
200
+ ### Added
201
+
202
+ - `macpm-sensors` / `macpm.sensors` — read SMC temperatures and fan speeds
203
+ without root (read-only).
204
+ - `macpm-dump` / `macpm.dump` — print the rootless metrics as JSON for
205
+ debugging.
206
+ - Optional per-core view improvements and reset/peak handling retained from
207
+ 0.24.
208
+ - `--version` flag.
209
+ - Compatibility notes for macOS 12–27, M1–M4 and partial M5/Ultra support.
210
+
211
+ ### Fixed
212
+
213
+ - `--show_cores` now accepts a real boolean value and `--show_cores` alone.
214
+ - Zero-division guards for `--avg < --interval` and for chips without E cores.
215
+ - No child `powermetrics` process is left behind when the TUI exits.
216
+ - `ioreg` output is filtered at the source to avoid retaining tens of MB of
217
+ XML in the Python allocator.
218
+ - Only the required `Energy Model` channels are subscribed, reducing memory
219
+ and CPU usage.
220
+
221
+ ### Removed
222
+
223
+ - `sudo echo` pre-authentication and the `sudo nice powermetrics` subprocess.
224
+ - The `macpm2` development package (merged into `macpm`).
225
+
226
+ ## 0.24
227
+
228
+ - Last 0.x release: `sudo` + `powermetrics` based sampler, Python TUI with
229
+ CPU/GPU/ANE power, RAM, disk and network panels.
@@ -4,3 +4,4 @@ include RELEASE.md
4
4
  include LICENSE
5
5
  recursive-include packaging *
6
6
  recursive-include tests *.py
7
+ recursive-include docs *.md
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: macpm
3
- Version: 2.2
4
- Summary: Rootless performance monitoring CLI tool for Apple Silicon
3
+ Version: 3.0
4
+ Summary: Performance monitoring CLI for Apple Silicon and Linux
5
5
  Home-page: https://github.com/visualcjy/macpm
6
6
  Author: Jinyu Chen
7
7
  Author-email: visualcjy@mail.com
@@ -9,7 +9,7 @@ License: MIT
9
9
  Project-URL: Source, https://github.com/visualcjy/macpm
10
10
  Project-URL: Issues, https://github.com/visualcjy/macpm/issues
11
11
  Project-URL: Changelog, https://github.com/visualcjy/macpm/blob/main/CHANGELOG.md
12
- Keywords: macpm apple-silicon monitor performance ioReport psutil
12
+ Keywords: macpm apple-silicon linux monitor performance ioReport psutil
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Operating System :: MacOS
20
+ Classifier: Operating System :: POSIX :: Linux
20
21
  Classifier: Environment :: Console
21
22
  Classifier: Topic :: System :: Monitoring
22
23
  Requires-Python: >=3.9
@@ -41,12 +42,27 @@ Dynamic: summary
41
42
 
42
43
  # macpm
43
44
 
44
- **Rootless performance monitoring CLI for Apple Silicon.**<br>
45
- macpm 2.2 reads the same hardware counters as `powermetrics`, but through
46
- IOReport/IOKit/SMC — no `sudo`, no password, no privileged helper.
45
+ **Performance monitoring CLI for Apple Silicon — and now Linux.**<br>
46
+ On macOS, macpm reads the same hardware counters as `powermetrics`, but through
47
+ IOReport/IOKit/SMC — no `sudo`, no password, no privileged helper. On Linux it
48
+ reads `/proc`, `/sys` and (optionally) RAPL, and tells you exactly which
49
+ readings need root.
47
50
 
48
51
  A Python-based `nvtop`-inspired terminal monitor for Apple Silicon Macs,
49
- forked from [asitop](https://github.com/tlkh/asitop).
52
+ forked from [asitop](https://github.com/tlkh/asitop), with an x86_64/arm64
53
+ Linux backend.
54
+
55
+ ## What's new in 3.0
56
+
57
+ - **Runs on Linux** (x86_64/arm64/LoongArch64) from the same package: `/proc`
58
+ and `/sys` sampling, root-aware capabilities, and `n/a` instead of fake
59
+ zeros. See [Linux support](#linux-support).
60
+ - **GPU view built for servers** (key `5`): one table, two lines per card, a
61
+ GPU INFO box, 10-cell VRAM bars, pagination and the served model name.
62
+ Verified on 16× Iluvatar BI-V150S, 64× Denglin KS58, 8× Techo
63
+ TECO_AICARD_01 and 8× RTX 4090.
64
+ - **Vendor and NVIDIA backends**: `ixsmi`, `dlsmi`, `teco-smi` and
65
+ `nvidia-smi`, including per-card compute processes and model names.
50
66
 
51
67
  ## Demo
52
68
 
@@ -83,13 +99,18 @@ Network view (press `4` while running):
83
99
  - Process view (`3`) with per-process CPU, memory and GPU usage, sortable with `s`
84
100
  - Network view (`4`) with TCP state counts, listening ports, per-process traffic
85
101
  and the local/public IP, gateway and city
102
+ - GPU view (`5`) with utilisation, clock, power, VRAM, temperature and the
103
+ processes using the GPU, ranked by GPU time
86
104
  - Key-hint footer in every view; the default view also fills the terminal and
87
105
  shows the network identity in the processor box when there is room
88
106
  - Familiar terminal layout, colours, charts and key bindings from macpm 0.x
89
107
 
90
108
  ## Install
91
109
 
92
- Requirements: **Apple Silicon Mac**, **macOS 12+**, **Python 3.9+**.
110
+ Requirements: **Apple Silicon Mac** with **macOS 12+**, or **Linux**
111
+ (x86_64/arm64) with `/proc`, `/sys` and **Python 3.9+**. On Linux the optional
112
+ pieces are `ss` (iproute2) for the per-process network table and root for CPU
113
+ power / GPU / other users' processes.
93
114
 
94
115
  ```sh
95
116
  python3 -m pip install --upgrade macpm
@@ -127,10 +148,10 @@ The default view also has a footer with the key hints. Keys:
127
148
  ```text
128
149
  q / ESC quit
129
150
  ← / → change colour
130
- 1 / 2 / 3 / 4 default / per-core / process / network view
131
- s cycle the sort column (process / network view)
151
+ 1 / 2 / 3 / 4 / 5 default / per-core / process / network / GPU view
152
+ s cycle the sort column (process / network / GPU view)
132
153
  ↑ / ↓ scroll the list or the focused network pane
133
- Space pause / resume the list (process / network view)
154
+ Space pause / resume the list (process / network / GPU view)
134
155
  Tab switch the focused network pane
135
156
  Ctrl+R reset peaks
136
157
  ```
@@ -274,6 +295,92 @@ listening table. Three limitations follow from the data source:
274
295
  - Process names are truncated to about 15 characters, the same `comm` limit
275
296
  shown in the process view.
276
297
 
298
+ ## GPU view
299
+
300
+ Press `5` for a GPU overview. A **GPU INFO** box at the top carries the
301
+ vendor's identity — full card name, device count, cards, dies per card, driver,
302
+ CUDA, PCIe link and VBIOS — and below it the cards are listed, two lines each:
303
+ the metrics line (utilisation bar, clock, power, a 10-cell VRAM usage bar,
304
+ temperature) and the processes running on that card
305
+ (`PID NAME [cards] GPU% MEM`). A process holding several cards is
306
+ repeated on every card it holds, with its range in brackets (`[8-9]`), so a card
307
+ that shows memory usage always shows the process behind it; a card with more
308
+ processes than fit shows `… +N`. `s` orders the processes inside each card
309
+ by PID → NAME → MEM, `↑` / `↓` turn a whole page (the footer shows `Page 2/5`),
310
+ `Space` pauses. The served model name sits right-aligned on the process line,
311
+ recovered from the launcher's command line (`--served-model-name`, `--model`,
312
+ `--model-path`, `--model-id`) by walking up the parent chain; a single-GPU view
313
+ shows it as a `MODEL` column.
314
+
315
+ A single-GPU machine keeps the older layout: card summary on top, process table
316
+ below. Every view's footer starts with the app name and version
317
+ (`macpm v3.0 · q quit …`).
318
+
319
+ ```text
320
+ ┌ GPU INFO ────────────────────────────────────────────────────────────────────────────────┐
321
+ │ AMD GPU (amdgpu) · 4 devices │
322
+ └──────────────────────────────────────────────────────────────────────────────────────────┘
323
+ ┌ GPUs (4) ─────────────────────────────────────────────────────────────────────────── 48W ┐
324
+ │ # NAME BUSY CLOCK POWER VRAM TEMP │
325
+ │ 0 AMD GPU (amdgpu) ▉▏▏▏▏▏ 10% 900/1750 12.0W ▉▏▏▏▏▏▏▏▏▏ 1.0G/8.0G 40°C │
326
+ │ └ 111 blender 1.0G │
327
+ │ 1 AMD GPU (amdgpu) ▉▉▏▏▏▏ 35% 1000/1750 12.0W ▉▉▏▏▏▏▏▏▏▏ 2.0G/8.0G 43°C │
328
+ │ └ 222 Xorg 2.0G │
329
+ │ 2 AMD GPU (amdgpu) ▉▉▉▉▏▏ 60% 1100/1750 12.0W ▉▉▉▉▏▏▏▏▏▏ 3.0G/8.0G 46°C │
330
+ │ 3 AMD GPU (amdgpu) ▉▉▉▉▉▏ 85% 1200/1750 12.0W ▉▉▉▉▉▏▏▏▏▏ 4.0G/8.0G 49°C │
331
+ └ macpm v3.0 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
332
+ ```
333
+
334
+ | Platform | What fills each row |
335
+ |---|---|
336
+ | macOS | One row: IOReport GPU idle ratio and the Energy Model power; the SMC supplies the temperature. Memory is unified, so the VRAM cell says `unified`. |
337
+ | Linux (amdgpu) | One row per `cardN`: `gpu_busy_percent`, `pp_dpm_sclk`, hwmon power/temperature, `mem_info_vram_*` |
338
+ | Linux (i915/xe) | One row per card: `gt_cur_freq_mhz` / `tile0/gt0/freq0`, DRM `fdinfo` engine time, hwmon temperature; VRAM only when the driver exposes `lmem_total_bytes` |
339
+ | Linux (NVIDIA) | One row per GPU from a single `nvidia-smi --query-gpu` call: utilisation, SM clock, power, memory, temperature. Compute processes come from `nvidia-smi --query-compute-apps` (SM% joined from `pmon`). `nvidia-smi` is found on `PATH`, at `/usr/lib/wsl/lib/nvidia-smi` on WSL, or via `MACPM_NVIDIA_SMI` |
340
+ | Linux (Iluvatar / 天数) | One row per GPU from `ixsmi --query-gpu` (the vendor's nvidia-smi clone): utilisation, clock, power, HBM, temperature. `ixsmi` is looked up on `PATH` and in `/usr/local/corex-*/bin`; override with `MACPM_IXSMI=/path/to/ixsmi` |
341
+ | Linux (Denglin / 登临) | One row per GPU from `dlsmi --query-gpu` (NVML-compatible): utilisation, clock, power, memory, temperature. Found on `PATH` or `/usr/bin/dlsmi`; override with `MACPM_DLSMI=/path/to/dlsmi` |
342
+ | Linux (Techo / 太初) | One row per device from `teco-smi --query-device` (its own property names: `utilization.spe`, `power.chip`, `clocks.spe`…). Found on `PATH`, `/opt/tecoai/bin/teco-smi` or via `MACPM_TECO=/path/to/teco-smi` |
343
+ | Other drivers | The card is still listed (so you can see that 8 accelerators exist) and probed for `gpu_busy_percent` / `busy_percent` / `utilization` / `load`, `devfreq/*/cur_freq`, `mem_info_*` and hwmon — whatever is missing shows `n/a` |
344
+
345
+ Linux, from the field — an 8×RTX 4090 node and an 8×Techo node where each
346
+ `teco-smi` device reports the same workers:
347
+
348
+ | RTX 4090 | Techo TECO_AICARD_01 |
349
+ |---|---|
350
+ | ![RTX 4090 GPU view](https://raw.githubusercontent.com/visualcjy/macpm/main/docs/screenshots/gpu-view-rtx4090.png) | ![Techo GPU view](https://raw.githubusercontent.com/visualcjy/macpm/main/docs/screenshots/gpu-view-teco.png) |
351
+
352
+ Notes:
353
+
354
+ - Enumeration covers every `/sys/class/drm/cardN` plus every NVIDIA GPU; cards
355
+ with no readable driver are listed with `n/a` rather than hidden.
356
+ - Cards and dies per card are derived from serials only when the vendor groups
357
+ devices per board: `ixsmi` shows 16 devices as 8 cards × 2 dies, `dlsmi` 64 as
358
+ 8 cards × 8 dies. `teco-smi` reports 8 cards of four SDAA dies each but does
359
+ not expose that grouping, so the INFO box shows only the device count.
360
+ - Model names come from the process tree, never from the model directory: the
361
+ worker is two hops below `vllm serve`/`sglang.launch_server`, and reading
362
+ `config.json` through `/proc/<pid>/root` can block on a stalled network mount.
363
+ Unknown servers show no name rather than a guess.
364
+ - The nested process line comes from the vendor's own compute-process list
365
+ (`ixsmi pmon`/`--query-compute-apps`, `dlsmi --query-compute-apps`,
366
+ `teco-smi pmon`) or, on macOS and DRM GPUs, from `fdinfo`/IOAccelerator. A
367
+ tool that reports no SM percentage makes the `GPU%` cell a dash, and a card
368
+ with more processes than fit shows `… +N`.
369
+ - Processes are merged per PID: one row, with the set of cards it holds. Card
370
+ numbers are compressed (`0-7`, `8-23`).
371
+ - The INFO box shows what the vendor tool reports: `ixsmi` gives driver and CUDA
372
+ versions, `dlsmi` and `teco-smi` only the driver, and `nvidia-smi` gives all of
373
+ them. Drivers that reject a field (580 refuses `cuda_version`) make the query
374
+ fall back to the remaining fields; the PCIe cell uses the link maximum so an
375
+ idle card does not read as generation 1. Consumer cards report `[N/A]` for
376
+ the serial, so their card/die counts are left out instead of guessed; PCIe
377
+ and VBIOS are hidden when the tool reports `N/A`.
378
+ - Intel `fdinfo` counters are machine-wide rather than per card; with more than
379
+ one Intel GPU the per-card BUSY cell shows `n/a` instead of duplicating the
380
+ aggregate on every row.
381
+ - The default view's GPU gauge shows the busiest card and appends `(max of N)`
382
+ when the machine has more than one.
383
+
277
384
  ## Compatibility
278
385
 
279
386
  Tested on macOS 27.2 with an M3 Max. Behaviour depends more on the chip
@@ -287,6 +394,111 @@ generation than on the macOS version:
287
394
  | macOS 15/26, M1/M2 Ultra | Needs verification: multi-die complex channels may be `ECPU0/1` |
288
395
  | macOS 27 | Works on the tested M3 Max; some 27 builds restrict unprivileged `Energy Model` refreshes |
289
396
  | Intel Macs | Not supported; the Apple-Silicon IOReport groups are absent |
397
+ | Linux x86_64 / arm64 / LoongArch64 | Supported; verified on 8×RTX 4090 (driver 580) and on Iluvatar/Denglin/Techo servers; see [Linux support](#linux-support) |
398
+
399
+ ## Linux support
400
+
401
+ macpm runs on x86_64, arm64 and LoongArch64 Linux with the same four views and
402
+ key bindings. The backend is chosen at runtime (`macpm.backend`), so the same
403
+ package serves both systems. Verified on 8×RTX 4090 (driver 580), 16×Iluvatar
404
+ BI-V150S, 64×Denglin KS58 and 8×Techo TECO_AICARD_01.
405
+
406
+ ### Run it
407
+
408
+ ```sh
409
+ python3 -m pip install macpm
410
+ macpm # normal user: CPU/RAM/disk/network/processes/temps
411
+ sudo macpm # root: adds CPU power, GPU utilisation and all processes
412
+ ```
413
+
414
+ Root is *recommended, not required*. Readings that need it are shown as `n/a`
415
+ instead of a misleading zero, and `macpm-dump --capabilities` prints exactly
416
+ what your kernel and permission level expose, and `python3 -m macpm.probe`
417
+ inventories the machine without needing psutil or a terminal (handy on compute
418
+ nodes):
419
+
420
+ ```sh
421
+ macpm-dump --capabilities
422
+ python3 -m macpm.probe
423
+ ```
424
+
425
+ ### What works
426
+
427
+ | Feature | Linux source | Without root | With root |
428
+ |---|---|---|---|
429
+ | CPU utilisation, per-core view, E/P split | `/proc/stat`, `topology/core_type`, `cpu_capacity` | ✅ | ✅ |
430
+ | CPU frequency | `cpufreq/scaling_cur_freq`, `stats/time_in_state` | ✅ | ✅ |
431
+ | CPU power | RAPL `energy_uj` | ❌ n/a | ✅ |
432
+ | GPU utilisation | amdgpu `gpu_busy_percent`, i915/xe DRM `fdinfo`, `nvidia-smi` | ✅ (see below) | ✅ |
433
+ | GPU frequency / power | `gt_cur_freq_mhz`, `pp_dpm_sclk`, hwmon | ✅ | ✅ |
434
+ | Temperatures / fans | hwmon (`coretemp`, `k10temp`, `amdgpu`, `macsmc`…) | ✅ | ✅ |
435
+ | Memory / swap | `psutil`, `/proc/meminfo` | ✅ | ✅ |
436
+ | Disk I/O, network rate | `/proc/diskstats`, `/proc/net/dev` | ✅ | ✅ |
437
+ | Processes CPU/MEM | `/proc/<pid>` via `psutil` | ✅ all users | ✅ |
438
+ | Per-process GPU% | DRM `fdinfo` `drm-engine-*` | own processes only | ✅ all |
439
+ | TCP/UDP counts, listeners | `/proc/net/{tcp,tcp6,udp,udp6}` | ✅ counts, own PIDs | ✅ all PIDs |
440
+ | Per-process traffic | `ss -tanie` `tcp_info` | own processes, TCP only | ✅ all |
441
+
442
+ **GPU notes.** `amdgpu` exposes everything. Intel `i915`/`xe` have no global
443
+ busy counter, so macpm sums every DRM client's engine time from `fdinfo` —
444
+ which needs root to see other processes, otherwise it only shows macpm's own
445
+ GPU work. NVIDIA uses `nvidia-smi`. Vendor ARM GPUs and Apple GPU under
446
+ Asahi have no exported counters yet and show `n/a`.
447
+
448
+ **No ANE.** There is no Linux equivalent of the Apple Neural Engine counter,
449
+ so that gauge is removed on Linux.
450
+
451
+ **Vendor accelerators need a vendor tool.** Ampere/Intel/AMD GPUs expose
452
+ kernel counters, but many accelerator cards only ship a management CLI and no
453
+ DRM node at all. macpm drives them through the vendor's NVML-style tool:
454
+ `ixsmi` for Iluvatar (天数), `dlsmi` for Denglin (登临) and `teco-smi` for
455
+ Techo (太初), one row per card, with each tool's own query switch
456
+ (`--query-gpu` / `--query-device`) and property names mapped onto the same
457
+ fields. Display adapters (ASPEED BMC, EFI framebuffer) are ignored on
458
+ purpose. Per-process GPU time still needs a driver that reports it (`ixsmi
459
+ pmon`); Each tool's compute-process list feeds the process table: `ixsmi pmon` joined
460
+ with `--query-compute-apps` (memory), `dlsmi --query-compute-apps` and
461
+ `teco-smi pmon`. One row per PID with the cards it holds (`0-7` for a process
462
+ spanning eight devices), its card memory and the vendor's GPU% when the tool
463
+ reports one — `ixsmi` and `teco-smi` do, `dlsmi` does not, so that column shows
464
+ `—` instead of a fake 0.
465
+
466
+ **No per-process traffic without `ss`.** Linux has no per-process byte
467
+ counter; macpm derives it from the kernel's `tcp_info` dump (`ss -tanie`),
468
+ joined to socket owners by inode. The traffic table is therefore TCP-only and
469
+ omits UDP. `ss` ships with iproute2 on every desktop distribution.
470
+
471
+ **Memory panel.** Linux has no `wired` memory; the process view's detail line
472
+ shows `cached` / `buffers` / `slab` / `free` instead.
473
+
474
+ ### Known differences from macOS
475
+
476
+ - Clusters are detected, not reported: an Intel hybrid or big.LITTLE machine
477
+ gets an E/P split, everything else a single `CPU Usage` gauge.
478
+ - Without `time_in_state` (e.g. `intel_pstate`, many ARM cpufreq drivers) the
479
+ average frequency is the mean of `scaling_cur_freq`, not a residency-weighted
480
+ average.
481
+ - `thermal_pressure` is approximated from PSI (`/proc/pressure/cpu`) and the
482
+ x86 throttle counters, not from a thermal speed limit.
483
+ - Containers and VMs see the host's counters or nothing at all; test on bare
484
+ metal.
485
+
486
+ ### Development knobs
487
+
488
+ Two environment variables make the Linux backend testable anywhere (including
489
+ on a Mac):
490
+
491
+ ```sh
492
+ # Replay a captured tree instead of the live /proc and /sys:
493
+ MACPM_SYSROOT=/tmp/captured-root macpm-dump --capabilities
494
+
495
+ # Force the Linux backend (with the captured tree above):
496
+ MACPM_SYSROOT=/tmp/captured-root MACPM_PLATFORM=linux macpm
497
+ ```
498
+
499
+ `tests/linux_fixtures.py` builds such a tree (hybrid x86, arm64 big.LITTLE and
500
+ an empty machine) and the test suite runs the full Linux sampler and the
501
+ headless UI against it.
290
502
 
291
503
  ## Standalone binaries
292
504
 
@@ -314,6 +526,16 @@ python3 -m pip install -e .
314
526
  python3 -m unittest discover -s tests -v
315
527
  ```
316
528
 
529
+ The Linux backend is tested on any platform through a fixture tree; no Linux
530
+ machine is needed to run the suite:
531
+
532
+ ```sh
533
+ python3 -m unittest discover -s tests -v
534
+ ```
535
+
536
+ `tests/linux_fixtures.py` builds the fake `/proc` + `/sys` trees, and
537
+ `MACPM_SYSROOT` points the sampler at one so `macpm-dump` can be replayed.
538
+
317
539
  Build source and wheel distributions:
318
540
 
319
541
  ```sh
@@ -347,6 +569,14 @@ Release steps are documented in [RELEASE.md](https://github.com/visualcjy/macpm/
347
569
  reader only reports the keys that are present.
348
570
  - **The network view says `nettop unavailable`** — `/usr/bin/nettop` is
349
571
  missing or could not run. The other views keep working.
572
+ - **Linux shows `n/a` for power or GPU** — run as root (or add a udev rule that
573
+ makes `/sys/class/powercap/intel-rapl:*/energy_uj` group-readable). Run
574
+ `macpm-dump --capabilities` to see which source was found.
575
+ - **Linux: no per-process traffic** — install `iproute2` (`ss`) and run as
576
+ root to see other users' sockets.
577
+ - **Linux: wrong CPU names or no E/P split** — the kernel does not expose
578
+ `topology/core_type` or `cpu_capacity`; macpm falls back to max-frequency
579
+ grouping and then to a single cluster.
350
580
  - **The network header has no public IP** — the lookup is disabled with
351
581
  `--no-public-ip`, or the machine is offline / the service is blocked. The
352
582
  local IP, prefix and gateway still show.