未加星标

Getting the GPU usage of NVIDIA cards with the Linux dstat tool

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏
Programming
Getting the GPU usage of NVIDIA cards with the Linux dstat tool
The dstat is an awesome little tool which allows you to get resource statistics for your linux box. It has a modular architecture which allows you to develop additional plugins and it’s easy to use. Recently I was profiling a Deep Learning pipeline developed with Keras and Tensorflow and I needed detailed statistics about the CPU, Hard Disk and GPU usage. The first two are available out-of-the-box by dstat, nevertheless as far as I know there is no plugin for monitoring GPU usage for NVIDIA graphics cards.

Thankfully it is super easy to write a python plugin for dstat. I have already sent a pull-request on the official repo but since new versions are released relatively rarely here are some instructions on how to set up the dstat NVIDIA GPU usage plugin on your box.

Installation

The following commands are tested on Ubuntu 16.04 and they will help you install dstat, the Python NVIDIA Management Library and my dstat nvidia plugin:

sudo apt-get install dstat #install dstat
sudo pip install nvidia-ml-py #install Python NVIDIA Management Library
wget https://raw.githubusercontent.com/datumbox/dstat/bc4326cbfa695db7d5dd45d7b3e04821196cc0f4/plugins/dstat_nvidia_gpu.py
sudo mv dstat_nvidia_gpu.py /usr/share/dstat/ #move file to the plugins directory of dstat

To get all the default statistics along with GPU usage (percentage) type the following command:

dstat -a --nvidia-gpu
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- gpu-n
usr sys idl wai hiq siq| read writ| recv send| in out | int csw | gpu
2 1 96 0 0 0|5816k 15M| 0 0 | 0 0 | 45k 98k| 68
0 1 98 0 0 0| 57M 128k| 104B 902B| 0 0 | 42k 85k| 50
8 7 84 1 0 0| 152M 0 | 292B 448B| 0 0 | 52k 93k| 39
1 1 97 1 0 0| 111M 0 | 52B 374B| 0 0 | 51k 116k| 62
0 1 98 1 0 0| 129M 0 | 80B 416B| 0 0 | 43k 85k| 92
0 2 98 0 0 0| 0 0 | 52B 374B| 0 0 | 41k 83k| 81 How it works

The plugin fetches the number of available GPUs on the system and samples 10 times the usage metric for each GPU. Sampling multiple times will hopefully return smoother metrics than getting a single measurement. After that it averages the usage across all GPUs and returns the results to the user. The source code of the plugin is available here .

Hope you enjoy it, happy GPU programming!

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LinuxCPUUbuntuPython
分页:12
转载请注明
本文标题:Getting the GPU usage of NVIDIA cards with the Linux dstat tool
本站链接:http://www.codesec.net/view/532597.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(88)