nvitop/examples/collector-background
2026-05-16 15:37:30 +08:00
..
collector_background.py chore: update license header 2026-05-16 15:37:30 +08:00
README.md feat(examples): add examples/ folder and relocate the deprecated nvitop.callbacks (#216) 2026-05-16 15:34:29 +08:00

Background ResourceMetricCollector

Demonstrates nvitop.collect_in_background: the collector ticks on a daemon thread, calls your on_collect callback with each sample, and shuts itself down cleanly when the callback returns False. A small InMemoryLogger stands in for whatever sink (TensorBoard, file, Slack webhook, …) you would normally write to.

APIs Used

The same pattern is available as a one-liner via ResourceMetricCollector.daemonize.

Run

python3 examples/collector-background/collector_background.py

The script collects in the background for ~10 seconds and prints each tick.

See ../README.md for the full example index.