当前位置:网站首页>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
?
边栏推荐
- 树莓派入门(5)系统备份
- Build Zabbix Kubernetes cluster monitoring platform
- LeetCode热题(12.买卖股票的最佳时机)
- Environment configuration of ESP32 (arduino arduino2.0 VScode platform which is easy to use?)
- 学编程的第十三天
- 你不知道的 console.log 替代品
- Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
- LeetCode刷题第11天字符串系列之《 58最后一个单词长度》
- 【FPGA】day18-ds18b20实现温度采集
- LeetCode刷题第17天之《3 无重复字符的最长子串》
猜你喜欢
LeetCode刷题第17天之《3 无重复字符的最长子串》
Kubernetes集群搭建Zabbix监控平台
【FPGA】day20-I2C读写EEPROM
leetCode刷题14天二叉树系列之《 110 平衡二叉树判断》
【FPGA】设计思路——I2C协议
DNS分离解析和智能解析
Graphical LeetCode - 640. Solving Equations (Difficulty: Moderate)
Read the article, high-performance and predictable data center network
What is Machine Reinforcement Learning?What is the principle?
电力机柜数据监测RTU
随机推荐
[ADI low-power 2k code] Based on ADuCM4050, ADXL363, TMP75 acceleration, temperature detection and serial port printing, buzzer playing music (lone warrior)
uni-app - 城市选择索引列表 / 通过 A-Z 排序的城市列表(uview 组件库 IndexList 索引列表)
What is ensemble learning in machine learning?
STC8H development (15): GPIO drive Ci24R1 wireless module
Watch to monitor
Qnet Weak Network Test Tool Operation Guide
按摩椅控制板的开发让按摩椅变得简约智能
电力机柜数据监测RTU
电商项目——商城限时秒杀功能系统
Unity2D animation (1) introduction to Unity scheme - animation system composition and the function of use
Redis老了吗?Redis与Dragonfly性能比较
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
LeetCode热题(12.买卖股票的最佳时机)
Homework 8.10 TFTP protocol download function
Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
js 将字符串作为js执行代码使用
荣威imax8ev魔方电池安全感,背后隐藏着哪些黑化膨胀?
C language recv() function, recvfrom() function, recvmsg() function
oracle的基数会影响到查询速度吗?