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.56k stars 144 forks source link

feat(api/device): add methods to query PCIe and NVLink throughput #87

Closed XuehaiPan closed 1 year ago

XuehaiPan commented 1 year ago

Issue Type

Description

Add methods to query PCIe and NVLink throughput.

In [1]: from nvitop import *

In [2]: d = Device(0)

In [3]: d.nvlink_mean_tx_throughput_human()  # mean TX throughput over all NVLinks
Out[3]: '257.6MiB/s'

In [4]: d.nvlink_tx_throughput_human()  # we have 12-NVLinks
Out[4]: 
['234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s',
 '234.7MiB/s']

In [5]: d.nvlink_rx_throughput_human()  # we have 12-NVLinks
Out[5]: 
['2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s',
 '2700MiB/s']

In [6]: d.nvlink_throughput()  # we have 12-NVLinks
Out[6]: 
[ThroughputInfo(tx=2619858, rx=2596953),  # in KiB/s
 ThroughputInfo(tx=2619815, rx=2596953),
 ThroughputInfo(tx=2619939, rx=2596953),
 ThroughputInfo(tx=2619939, rx=2596953),
 ThroughputInfo(tx=2619860, rx=2596953),
 ThroughputInfo(tx=2619860, rx=2596953),
 ThroughputInfo(tx=2619860, rx=2596953),
 ThroughputInfo(tx=2619819, rx=2596953),
 ThroughputInfo(tx=2619942, rx=2596953),
 ThroughputInfo(tx=2619939, rx=2596953),
 ThroughputInfo(tx=2619861, rx=2596953),
 ThroughputInfo(tx=2619861, rx=2596953)]

In [7]: d.pcie_throughput()  # in KiB/s
Out[7]: ThroughputInfo(tx=7000, rx=12000)

In [8]: d.pcie_tx_throughput()  # in KiB/s
Out[8]: 11000

In [9]: d.pcie_tx_throughput_human()
Out[9]: '6.84MiB/s'

Motivation and Context

Resolves #82