当前位置:网站首页>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 12195MiBsed "s/\([0-9]\{1,\}\)MiB \([0-9]\{1,\}\)MiB/\1 \2/"Remove theMiBsuffix (brackets enclose the matching group,\1,\2refer to the matched string), get:8481 12195awk '{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?
边栏推荐
- How can users overcome emotional issues in programmatic trading?
- oracle的基数会影响到查询速度吗?
- Design and Realization of Employment Management System in Colleges and Universities
- 云平台下ESB产品开发步骤说明
- Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
- Interchangeability and Measurement Techniques - Tolerance Principles and Selection Methods
- 【FPGA】abbreviation
- typedef定义结构体数组类型
- AI + medical: for medical image recognition using neural network analysis
- 元素的BFC属性
猜你喜欢
随机推荐
我的 archinstall 使用手册
The solution to the height collapse problem
QueryDet: Cascading Sparse Query Accelerates Small Object Detection at High Resolution
元素的BFC属性
How to delete statements audit log?
【FPGA】day18-ds18b20实现温度采集
程序化交易改变了什么?
Enter the starting position, the ending position intercepts the linked list
What is third-party payment?
AI+医疗:使用神经网络进行医学影像识别分析
【FPGA】名词缩写
App Basic Framework Construction丨Log Management - KLog
学编程的第十三天
"110 Balanced Binary Tree Judgment" in leetCode's 14-day binary tree series
Interchangeability and Measurement Techniques - Tolerance Principles and Selection Methods
LeetCode814算题第15天二叉树系列值《814 二叉树剪枝》
Description of ESB product development steps under cloud platform
没想到MySQL还会问这些...
按摩椅控制板的开发让按摩椅变得简约智能
LeetCode Hot Questions (12. The Best Time to Buy and Sell Stocks)



![Binary tree related code questions [more complete] C language](/img/85/a109eed69cd54be3c8290e8dd67b7c.png)
![[C Language] Getting Started](/img/5e/484e3d426a6f1cc0d792a9ba330695.png)



