我试图监控一个使用CUDA和MPI的进程,有没有办法我可以做到这一点,像命令“顶部”,但也监控GPU ?


当前回答

使用参数"——query-compute-apps="

nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv

如需进一步帮助,请关注

nvidia-smi --help-query-compute-app

其他回答

在设备监控模式下运行nvidia-smi,例如:

$ nvidia-smi dmon -d 3 -s pcvumt
# gpu   pwr gtemp mtemp  mclk  pclk pviol tviol    sm   mem   enc   dec    fb  bar1 rxpci txpci
# Idx     W     C     C   MHz   MHz     %  bool     %     %     %     %    MB    MB  MB/s  MB/s
    0   273    54     -  9501  2025     0     0   100    11     0     0 18943    75  5906   659
    0   280    54     -  9501  2025     0     0   100    11     0     0 18943    75  7404   650
    0   277    54     -  9501  2025     0     0   100    11     0     0 18943    75  7386   719
    0   279    55     -  9501  2025     0     0    99    11     0     0 18945    75  6592   692
    0   281    55     -  9501  2025     0     0    99    11     0     0 18945    75  7760   641
    0   279    55     -  9501  2025     0     0    99    11     0     0 18945    75  7775   668
    0   279    55     -  9501  2025     0     0   100    11     0     0 18947    75  7589   690
    0   281    55     -  9501  2025     0     0    99    12     0     0 18947    75  7514   657
    0   279    55     -  9501  2025     0     0   100    11     0     0 18947    75  6472   558
    0   280    54     -  9501  2025     0     0   100    11     0     0 18947    75  7066   683

完整的细节在man nvidia-smi。

您可以使用监控程序glances及其GPU监控插件:

开源 安装方法:sudo apt-get install -y python-pip;Sudo PIP安装[gpu] 启动:sudo扫视

它还监视CPU、磁盘IO、磁盘空间、网络和其他一些东西:

使用参数"——query-compute-apps="

nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv

如需进一步帮助,请关注

nvidia-smi --help-query-compute-app

另一种有用的监控方法是对消耗gpu的进程使用ps过滤。我经常用这个:

ps f -o user,pgrp,pid,pcpu,pmem,start,time,command -p `lsof -n -w -t /dev/nvidia*`

这将显示所有nvidia gpu利用进程和一些统计数据。lsof……检索当前用户拥有的nvidia GPU的所有进程的列表,并且ps -p…显示这些进程的ps结果。Ps f显示子/父进程关系/层次结构的良好格式,-o指定自定义格式。这个类似于ps u,但添加了进程组ID并删除了一些其他字段。

这与nvidia-smi相比的一个优点是,它将显示使用GPU的主进程以及进程分叉。

但是,它的一个缺点是它仅限于执行该命令的用户拥有的进程。为了将其开放给任何用户拥有的所有进程,我在lsof之前添加了一个sudo。

最后,我将它与手表结合起来,以获得持续的更新。所以,在最后,它看起来像:

watch -n 0.1 'ps f -o user,pgrp,pid,pcpu,pmem,start,time,command -p `sudo lsof -n -w -t /dev/nvidia*`'

它的输出如下:

Every 0.1s: ps f -o user,pgrp,pid,pcpu,pmem,start,time,command -p `sudo lsof -n -w -t /dev/nvi...  Mon Jun  6 14:03:20 2016
USER      PGRP   PID %CPU %MEM  STARTED     TIME COMMAND
grisait+ 27294 50934  0.0  0.1   Jun 02 00:01:40 /opt/google/chrome/chrome --type=gpu-process --channel=50877.0.2015482623
grisait+ 27294 50941  0.0  0.0   Jun 02 00:00:00  \_ /opt/google/chrome/chrome --type=gpu-broker
grisait+ 53596 53596 36.6  1.1 13:47:06 00:05:57 python -u process_examples.py
grisait+ 53596 33428  6.9  0.5 14:02:09 00:00:04  \_ python -u process_examples.py
grisait+ 53596 33773  7.5  0.5 14:02:19 00:00:04  \_ python -u process_examples.py
grisait+ 53596 34174  5.0  0.5 14:02:30 00:00:02  \_ python -u process_examples.py
grisait+ 28205 28205  905  1.5 13:30:39 04:56:09 python -u train.py
grisait+ 28205 28387  5.8  0.4 13:30:49 00:01:53  \_ python -u train.py
grisait+ 28205 28388  5.3  0.4 13:30:49 00:01:45  \_ python -u train.py
grisait+ 28205 28389  4.5  0.4 13:30:49 00:01:29  \_ python -u train.py
grisait+ 28205 28390  4.5  0.4 13:30:49 00:01:28  \_ python -u train.py
grisait+ 28205 28391  4.8  0.4 13:30:49 00:01:34  \_ python -u train.py

在Linux Mint和Ubuntu中,你可以尝试"nvidia-smi——loop=1"