当前位置:网站首页>shell monitors gpu usage
shell monitors gpu usage
2022-08-11 03:52:00 【HackerTom】
The output of a nvidia-smi
looks like this:
Tue Aug 9 23:05:08 2022+-----------------------------------------------------------------------------+| NVIDIA-SMI 440.44 Driver Version: 440.44 CUDA Version: 10.2 ||-------------------------------+----------------------+----------------------+| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. ||================================+=======================+========================|| 0 TITAN Xp Off | 00000000:01:00.0 Off | N/A || 37% 58C P2 75W / 250W | 8481MiB / 12195MiB | 2% Default |+--------------------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+| Processes: GPU Memory || GPU PID Type Process name Usage ||=================================================================================|| 0 2292 C python 8467MiB |+-----------------------------------------------------------------------------+
Where 8481MiB / 12195MiB
shows the used video memory and the total amount of video memory.Now use the shell command to calculate the available video memory size:
nvidia-smi | \grep -E "[0-9]+MiB\s*/\s*[0-9]+MiB" | \awk '{print ($9" "$11)}' | \sed "s/\([0-9]\{1,\}\)MiB \([0-9]\{1,\}\)MiB/\1 \2/" | \awk '{print $2 - $1}'
Where:
|
pipeline, pass the result of the previous command to the next command;\
continue;grep -E "[0-9]+MiB\s*/\s*[0-9]+MiB"
Filter out the line of output that contains usage, get:| 37% 58C P2 75W / 250W | 8481MiB / 12195MiB | 2% Default |
awk '{print ($9" "$11)}'
filters out the core data of used video memory and total video memory (here are the 9th and 11th columns of the row),Open the space, get:8481MiB 12195MiB
sed "s/\([0-9]\{1,\}\)MiB \([0-9]\{1,\}\)MiB/\1 \2/"
Remove theMiB
suffix (brackets enclose the matching group,\1
,\2
refer to the matched string), get:8481 12195
awk '{print $2 - $1}'
Calculate the difference between two columns and calculate the available video memory, get:3714
This is the case of a single card, if there are multiple cards, maybe |
should be used with xarg
?
边栏推荐
猜你喜欢
【FPGA】SDRAM
EasyCVR接入海康大华设备选择其它集群服务器时,通道ServerID错误该如何解决?
What is ensemble learning in machine learning?
Getting Started with Raspberry Pi (5) System Backup
这些云自动化测试工具值得拥有
LeetCode刷题第10天字符串系列之《125回文串验证》
I didn't expect MySQL to ask these...
[FPGA] Design Ideas - I2C Protocol
【C语言】入门
Interchangeability and Measurement Techniques - Tolerance Principles and Selection Methods
随机推荐
QueryDet:级联稀疏query加速高分辨率下的小目标检测
LeetCode Hot Questions (12. The Best Time to Buy and Sell Stocks)
什么是三方支付?
C language recv() function, recvfrom() function, recvmsg() function
Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
【FPGA】abbreviation
你不知道的 console.log 替代品
元素的BFC属性
I didn't expect MySQL to ask these...
Leetcode 450. 删除二叉搜索树中的节点
浅析一下期货程序化交易好还是手工单好?
【FPGA】day20-I2C读写EEPROM
DNS separation resolution and intelligent resolution
程序化交易改变了什么?
Interchangeability Measurements and Techniques - Calculation of Deviations and Tolerances, Drawing of Tolerance Charts, Selection of Fits and Tolerance Classes
C语言 recv()函数、recvfrom()函数、recvmsg()函数
【FPGA】名词缩写
Get the length of the linked list
The development of the massage chair control panel makes the massage chair simple and intelligent
【FPGA】day19-二进制转换为十进制(BCD码)