当前位置:网站首页>shell监视gpu使用情况
shell监视gpu使用情况
2022-08-11 03:48:00 【HackerTom】
一次 nvidia-smi
的输出形如:
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 |
+-----------------------------------------------------------------------------+
其中 8481MiB / 12195MiB
显示了已用显存、显存总量。现用 shell 命令计算可用显存大小:
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}'
其中:
|
管道,将前一命令结果传给后一命令;\
续行;grep -E "[0-9]+MiB\s*/\s*[0-9]+MiB"
筛出包含使用情况的那行输出,得:| 37% 58C P2 75W / 250W | 8481MiB / 12195MiB | 2% Default |
awk '{print ($9" "$11)}'
筛出已用显存、显存总量两列核心数据(这里是该行的第 9 列和第 11 列),空格间开,得:8481MiB 12195MiB
sed "s/\([0-9]\{1,\}\)MiB \([0-9]\{1,\}\)MiB/\1 \2/"
去掉MiB
后缀(括号括住匹配组,\1
、\2
引用匹配到的字符串),得:8481 12195
awk '{print $2 - $1}'
计算两列的差,算得可用显存,得:3714
这是单张卡的情况,如果有多张卡,可能 |
要配合 xarg
用?
边栏推荐
- MongoDB 基础了解(二)
- 机器学习中什么是集成学习?
- 我的 archinstall 使用手册
- Interchangeability and Measurement Technology—Surface Roughness Selection and Marking Method
- QueryDet:级联稀疏query加速高分辨率下的小目标检测
- 怎么删除语句审计日志?
- Will oracle cardinality affect query speed?
- Interchangeable Measurement Techniques - Geometric Errors
- 分布式和集群的区别和联系
- Leetcode 450. 删除二叉搜索树中的节点
猜你喜欢
Qnet Weak Network Test Tool Operation Guide
Interchangeability and Measurement Technology—Surface Roughness Selection and Marking Method
Interchangeability Measurements and Techniques - Calculation of Deviations and Tolerances, Drawing of Tolerance Charts, Selection of Fits and Tolerance Classes
Echart地图的省级,以及所有地市级下载与使用
[yu gong series] Go program 035-08 2022 interfaces and inheritance and transformation and empty interface
UNI-APP_iphone苹果手机底部安全区域
机器学习怎么学?机器学习流程
互换性与测量技术-公差原则与选用方法
没想到MySQL还会问这些...
STC8H development (15): GPIO drive Ci24R1 wireless module
随机推荐
C语言 recv()函数、recvfrom()函数、recvmsg()函数
Basic understanding of MongoDB (2)
LeetCode热题(12.买卖股票的最佳时机)
Description of ESB product development steps under cloud platform
LeetCode刷题第16天之《239滑动窗口最大值》
【ADI低功耗2k代码】基于ADuCM4050的ADXL363、TMP75的加速度、温度检测及串口打印、蜂鸣器播放音乐(孤勇者)
浮点数在内存中的存储方式
【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口
大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,如何分配?
常见布局效果实现方案
常用认证机制
Detailed explanation of VIT source code
AI + medical: for medical image recognition using neural network analysis
How to rebuild after pathman_config and pathman_config_params are deleted?
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
[ADI low-power 2k code] Based on ADuCM4050, ADXL363, TMP75 acceleration, temperature detection and serial port printing, buzzer playing music (lone warrior)
When EasyCVR is connected to the GB28181 device, what is the reason that the device is connected normally but the video cannot be played?
What problems should we pay attention to when building a programmatic trading system?
80端口和443端口是什么?有什么区别?
rac备库双节点查询到的表最后更新时间不一致