A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).
Python
Prime Intel device counters only for the selected GPU
Scott Hanselman26a1137f2b83
diff --git a/README.md b/README.mdindex d2c2d6f..b697e16 100644--- a/README.md+++ b/README.md@@ -260,7 +260,8 @@ The load readings sample every exposed `*-busy` engine instance, including compuvideo/copy engines, and use the busiest instance rather than averaging across idle engines. DiscretePMUs are matched by PCI address (`i915_<PCI BDF>`); the legacy `i915` PMU is used only for an integratedcard. If multiple cards resolve to the same PMU, their load stays `N/A` with an attribution reason.-Each collector owns its counter handles and baselines; closing one does not reset another collector's readings.+Each collector opens device counters only for its selected GPU and owns those handles and baselines;+closing one does not reset another collector's readings.`xe` cards are detected, but its fdinfo uses other keys (`drm-cycles-*`, `drm-resident-vram0`/`-gtt`), so itsper-process rows show `n/a` until they are decoded on hardware.diff --git a/src/gputaskman/collector.py b/src/gputaskman/collector.pyindex fb0b78c..6c3edb3 100644--- a/src/gputaskman/collector.py+++ b/src/gputaskman/collector.py@@ -228,7 +228,7 @@ class Collector:if drm is not None and self.drm_card is None:self.counters.drm = None # an NVIDIA GPU is shown: don't walk every process's fds for nothingelif drm is not None:- drm.start() # engine baseline over every process+ drm.start(self.drm_card) # process baseline plus device counters for the selected GPU onlyif scan_budget is None:drm.scan_budget = None # one-shot output sees every processself.inspector = ProcInspector()diff --git a/src/gputaskman/drm.py b/src/gputaskman/drm.pyindex 20fc7ab..605ff5e 100644--- a/src/gputaskman/drm.py+++ b/src/gputaskman/drm.py@@ -880,7 +880,7 @@ class DrmCounters:self.partial = False # the last scan ran out of budget, so a DRM client's holders may not all be knownself.scan_budget: float | None = SCAN_BUDGET- def start(self) -> None:+ def start(self, selected: DrmCard | None = None) -> None:"""Take the engine baseline over every process, like the WDDM counters do at startup."""if not self.ok:return@@ -888,11 +888,12 @@ class DrmCounters:self.sample()self.scan_budget = budgetintel_cards = [c for c in self.cards if c.intel]- for card in intel_cards:+ selected_intel = [c for c in intel_cards if selected is None or c is selected]+ for card in selected_intel:if card.integrated:_intel_rapl_w() # arm the power baseline; RAPL is package-global, unaffected by sharingpmu_paths = {card.sysfs: _intel_pmu_path(card) for card in intel_cards}- for card in intel_cards:+ for card in selected_intel:path = pmu_paths[card.sysfs]if path is not None and list(pmu_paths.values()).count(path) > 1:# Only a genuinely shared PMU is ambiguous; discrete PMUs are named by PCI address.diff --git a/tests/test_drm.py b/tests/test_drm.pyindex c33aec7..6fe17a4 100644--- a/tests/test_drm.py+++ b/tests/test_drm.py@@ -1663,6 +1663,29 @@ class IntelPmuTests(unittest.TestCase):second.close()self.assertEqual([call.args[0] for call in closed.call_args_list], [101, 102])+ def test_selected_amd_card_does_not_open_intel_device_counters(self):+ amd = _card("/x/amd/device", "0000:01:00.0")+ counters = drm.DrmCounters(found=[amd, self.card])+ with patch.object(counters, "sample"), \+ patch.object(drm, "_intel_pmu_rates") as pmu, \+ patch.object(drm, "_intel_rapl_w") as rapl:+ counters.start(amd)+ pmu.assert_not_called()+ rapl.assert_not_called()++ def test_selected_intel_card_primes_only_its_own_device_counters(self):+ other = drm.DrmCard(key=2, pdev="0000:03:00.0", sysfs="/x/card2/device", driver="i915",+ vendor_id=0x8086, device_id=1, name="Intel", vram_total=16 * GiB,+ integrated=False, intel=True)+ counters = drm.DrmCounters(found=[self.card, other])+ with patch.object(counters, "sample"), \+ patch.object(drm, "_intel_pmu_path", side_effect=lambda c: c.sysfs), \+ patch.object(drm, "_intel_pmu_rates") as pmu, \+ patch.object(drm, "_intel_rapl_w") as rapl:+ counters.start(other)+ pmu.assert_called_once_with(other)+ rapl.assert_not_called()+def test_failed_counter_closes_only_its_own_handles_and_retries(self):other = drm.DrmCard(key=2, pdev="0000:03:00.0", sysfs="/x/card2/device", driver="i915",vendor_id=0x8086, device_id=1, name="Intel", vram_total=16 * GiB,