Categories: DevOps

nvitop是一款实用、高颜值的GPU进程管理工具

nvitop是一款交互式NVIDIA设备和进程监控工具。它有一个丰富多彩的信息界面,可以不断更新设备和进程的状态。作为一款资源监控器,它包括许多功能和选项,如树视图、环境变量查看、流程过滤、流程度量监控等。除此之外,该包还为深度学习研究人员提供了CUDA设备选择工具nvisel。它还提供了方便的API,允许开发人员编写自己的监控工具。

特性

  • 信息和漂亮的输出:使用彩色的盒子绘图显示比nvidia-smi更多的信息。

  • 监视器模式:可以作为资源监视器运行,而不是只打印一次结果。

    • 条形图和历史图
    • 过程排序
    • 过程过滤
    • 通过按键向进程发送信号
    • GPU进程及其父进程的树视图屏幕
    • 环境变量屏幕
    • 帮助屏幕
    • 鼠标支持
  • 交互式:在显示器模式下响应用户输入(来自键盘和/或鼠标)。(与gpustat和py3nvml相比)

  • 高效

    • 直接使用NVML Python绑定查询设备状态,而不是解析nvidia-smi的输出。(vs. nvidia-htop)
    • 使用来自cachetools的TTLCache支持稀疏查询和缓存结果。(与gpustat相比)
    • 使用curss库显示信息,而不是用ANSI转义代码打印。(与py3nvml对)
    • 使用多线程异步收集信息,并更快地对应用户输入。(与nvtop)
  • 便携式:在Linux和Windows上工作。

    • 使用跨平台库psutil获取主机进程信息,而不是在子进程中调用ps -p 。(vs. nvidia-htop & py3nvml)
    • 用纯Python编写,易于使用pip安装。(vs. nvtop)
  • 可集成:易于集成到其他应用程序中,不仅仅是监控。(与nvidia-htop和nvtop相比)

依赖条件

  • Python 3.7+
  • NVIDIA Management Library (NVML)
  • nvidia-ml-py
  • psutil
  • cachetools
  • termcolor
  • curses* (with libncursesw)

安装

github地址: https://github.com/XuehaiPan/nvitop

以下是在Ubuntu系统下安装命令,其他系统类似

$ sudo apt install pip
$ pip install nvitop

使用nvitop, 可以实时监控显存的使用情况。

nvitop用法

usage: nvitop [--help] [--version] [--once | --monitor [{auto,full,compact}]] [--interval SEC] [--ascii] [--colorful]
              [--force-color] [--light] [--gpu-util-thresh th1 th2] [--mem-util-thresh th1 th2]
              [--only idx [idx ...]] [--only-visible] [--compute] [--only-compute] [--graphics] [--only-graphics]
              [--user [USERNAME ...]] [--pid PID [PID ...]]

举例

# Monitor mode (when the display mode is omitted, `NVITOP_MONITOR_MODE` will be used)
$ nvitop  # or use `python3 -m nvitop`

# Automatically configure the display mode according to the terminal size
$ nvitop -m auto     # shortcut: `a` key

# Arbitrarily display as `full` mode
$ nvitop -m full     # shortcut: `f` key

# Arbitrarily display as `compact` mode
$ nvitop -m compact  # shortcut: `c` key

# Specify query devices (by integer indices)
$ nvitop -o 0 1  # only show <GPU 0> and <GPU 1>

# Only show devices in `CUDA_VISIBLE_DEVICES` (by integer indices or UUID strings)
$ nvitop -ov

# Only show GPU processes with the compute context (type: 'C' or 'C+G')
$ nvitop -c

# Use ASCII characters only
$ nvitop -U  # useful for terminals without Unicode support

# For light terminals
$ nvitop --light

# For spectrum-like bar charts (requires the terminal supports 256-color)
$ nvitop --colorful

更多内容请参考https://github.com/XuehaiPan/nvitop

4.8
06
Git LFS 大文件储存工具
Git为github设置代理
嘻嘻

嘻嘻IT: 笔者是一个工作七八年的程序猿老鸟,从事涉及的技术栈主要包括PHP、Linux、Devops等,喜欢研究新技术,尝试新技术,提升技术自动化和开发效率,致力于write less,do more! 技术每年都会层出不穷,领域划分的越来越细,不可能学习所有的东西,保持对技术的好奇心,理解技术中核心思想,做一个有深度,有思想的开发!

Recent Posts

Linux中你必须知道的5个压缩命令

Linux系统具有丰富的包和解…

4小时 ago

Shell脚本定时执行的三种方法

Shell脚本是Unix和Li…

4小时 ago

Linux中你必须知道的5个解压缩命令

Linux操作系统中有许多强大…

4小时 ago

Golang如何实现三元表达式?

三元表达式又被称为条件表达式,…

5小时 ago

还不知道Unix和Linux有哪些不同?

随着技术的进步和全球范围内的数…

9小时 ago

Reality Defender一款抵御深度伪造威胁的工具

在数字欺诈猖獗的时代,Real…

10小时 ago