docs(core/collector): update docstrings

Signed-off-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
This commit is contained in:
Xuehai Pan 2022-07-05 10:54:33 +08:00
parent 2906d4f043
commit a35d3b9caf
2 changed files with 6 additions and 6 deletions

View file

@ -575,7 +575,7 @@ In [1]: from nvitop import ResourceMetricCollector, Device
...: import os
...: os.environ['CUDA_VISIBLE_DEVICES'] = '3,2,1,0' # comma-separated integers or UUID strings
In [2]: collector = ResourceMetricCollector() # log all devices and children processes of the current process on the GPUs
In [2]: collector = ResourceMetricCollector() # log all devices and descendant processes of the current process on the GPUs
In [3]: collector = ResourceMetricCollector(root_pids={1}) # log all devices and all GPU processes
In [4]: collector = ResourceMetricCollector(devices=Device(0), root_pids={1}) # log <GPU 0> and all GPU processes on <GPU 0>
In [5]: collector = ResourceMetricCollector(devices=Device.cuda.all()) # use the CUDA ordinal
@ -645,7 +645,7 @@ from nvitop.callbacks.tensorboard import add_scalar_dict
# Logger and status collector
writer = SummaryWriter()
collector = ResourceMetricCollector(devices=CudaDevice.all(), # log all visible CUDA devices and use the CUDA ordinal
root_pids={os.getpid()}, # only log the children processes of the current process
root_pids={os.getpid()}, # only log the descendant processes of the current process
interval=1.0) # snapshot interval for background daemon thread
# Start training

View file

@ -165,9 +165,9 @@ class ResourceMetricCollector: # pylint: disable=too-many-instance-attributes
Set of Device instances for logging. If not given, all physical
devices on board will be used.
root_pids (Set[int]):
A set of PIDs, only the status of the children processes on the GPUs
will be collected. If not given, the PID of the current process will
be used.
A set of PIDs, only the status of the descendant processes on the
GPUs will be collected. If not given, the PID of the current process
will be used.
interval (float): The snapshot interval for background daemon thread.
Core methods:
@ -187,7 +187,7 @@ class ResourceMetricCollector: # pylint: disable=too-many-instance-attributes
>>> from nvitop import ResourceMetricCollector, Device
>>> collector = ResourceMetricCollector() # log all devices and children processes of the current process on the GPUs
>>> collector = ResourceMetricCollector() # log all devices and descendant processes of the current process on the GPUs
>>> collector = ResourceMetricCollector(root_pids={1}) # log all devices and all GPU processes
>>> collector = ResourceMetricCollector(devices=Device.cuda.all()) # use the CUDA ordinal