XuehaiPan / nvitop

An interactive NVIDIA-GPU process viewer and beyond, the one-stop solution for GPU process management.
https://nvitop.readthedocs.io
Apache License 2.0
4.79k stars 149 forks source link

feat(core/collector): add function and method to collect metrics in background thread #48

Closed XuehaiPan closed 1 year ago

XuehaiPan commented 1 year ago

Issue Type

Runtime Environment

Description

Add a function to create a background daemon for metrics collectors.

A minimal example:

from nvitop import collect_in_background

def on_collect(metrics):
    print(metrics)
    return True

collect_in_background(on_collect)  # print metrics to stdout every 1 second

Motivation and Context

Resolves #47