0
点赞
收藏
分享

微信扫一扫

Bus-Id

写心之所想 2022-02-06 阅读 70
python
import re

txt = '''
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.77                 Driver Version: 390.77                    |
|-------------------------------+----------------------+----------------------+
| 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 |
| 24%   44C    P2    68W / 250W |  11743MiB / 12192MiB |     18%      Default |
+-------------------------------+----------------------+----------------------+
         
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     23265      C   python3                                    11733MiB |
+-----------------------------------------------------------------------------+
 '''

result = []
lines = txt.split("\n")
for line in lines:
    ret = re.search(r"([0-9A-F]{2}:[0-9A-F]{2}.[0-9A-F]{1})", line, re.I)
    if not ret:
        continue
    bdf_num = ret.group()
    cpu_idx = line.split()[1]
    result.append('|'.join((cpu_idx, bdf_num)))
print(1)
举报

相关推荐

0 条评论