rocmtop 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rocmtop-0.1.0/LICENSE +21 -0
- rocmtop-0.1.0/PKG-INFO +51 -0
- rocmtop-0.1.0/README.md +39 -0
- rocmtop-0.1.0/pyproject.toml +19 -0
- rocmtop-0.1.0/setup.cfg +4 -0
- rocmtop-0.1.0/src/rocmtop/__init__.py +1 -0
- rocmtop-0.1.0/src/rocmtop/cli.py +174 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/PKG-INFO +51 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/SOURCES.txt +11 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/dependency_links.txt +1 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/entry_points.txt +2 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/requires.txt +2 -0
- rocmtop-0.1.0/src/rocmtop.egg-info/top_level.txt +1 -0
rocmtop-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ziyang Zhai (Liam)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
rocmtop-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rocmtop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight ROCm GPU monitoring tool (like nvidia-smi top)
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: rich
|
|
10
|
+
Requires-Dist: readchar
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# rocmtop
|
|
14
|
+
|
|
15
|
+
**rocmtop** 是一个轻量级的 ROCm GPU 监控工具,可以在终端动态展示 AMD 显卡的状态(温度、功率、GPU 利用率和显存占用),类似于 `nvidia-smi top`。
|
|
16
|
+
|
|
17
|
+
用户可以直接通过终端使用:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install rocmtop
|
|
21
|
+
|
|
22
|
+
rocmtop
|
|
23
|
+
````
|
|
24
|
+
|
|
25
|
+
## 功能特点
|
|
26
|
+
|
|
27
|
+
* 实时刷新 GPU 状态(默认 0.5 秒刷新间隔)
|
|
28
|
+
* 彩色显示 GPU 温度、功率、利用率和显存占用
|
|
29
|
+
* 进度条直观显示 GPU 利用率
|
|
30
|
+
* 按 `q` 或 `Q` 退出
|
|
31
|
+
* 轻量、易用,无依赖复杂库,仅依赖 `rich` 和 `readchar`
|
|
32
|
+
|
|
33
|
+
## 安装
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install rocmtop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使用
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
rocmtop
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> 注意:需要在支持 ROCm 的 AMD 显卡上使用,并安装 `rocm-smi` 工具。
|
|
46
|
+
|
|
47
|
+
## 作者
|
|
48
|
+
```
|
|
49
|
+
Ziyang Zhai (Liam)
|
|
50
|
+
|
|
51
|
+
```
|
rocmtop-0.1.0/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# rocmtop
|
|
2
|
+
|
|
3
|
+
**rocmtop** 是一个轻量级的 ROCm GPU 监控工具,可以在终端动态展示 AMD 显卡的状态(温度、功率、GPU 利用率和显存占用),类似于 `nvidia-smi top`。
|
|
4
|
+
|
|
5
|
+
用户可以直接通过终端使用:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install rocmtop
|
|
9
|
+
|
|
10
|
+
rocmtop
|
|
11
|
+
````
|
|
12
|
+
|
|
13
|
+
## 功能特点
|
|
14
|
+
|
|
15
|
+
* 实时刷新 GPU 状态(默认 0.5 秒刷新间隔)
|
|
16
|
+
* 彩色显示 GPU 温度、功率、利用率和显存占用
|
|
17
|
+
* 进度条直观显示 GPU 利用率
|
|
18
|
+
* 按 `q` 或 `Q` 退出
|
|
19
|
+
* 轻量、易用,无依赖复杂库,仅依赖 `rich` 和 `readchar`
|
|
20
|
+
|
|
21
|
+
## 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install rocmtop
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 使用
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
rocmtop
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> 注意:需要在支持 ROCm 的 AMD 显卡上使用,并安装 `rocm-smi` 工具。
|
|
34
|
+
|
|
35
|
+
## 作者
|
|
36
|
+
```
|
|
37
|
+
Ziyang Zhai (Liam)
|
|
38
|
+
|
|
39
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rocmtop"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A lightweight ROCm GPU monitoring tool (like nvidia-smi top)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
"rich",
|
|
15
|
+
"readchar",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
rocmtop = "rocmtop.cli:main"
|
rocmtop-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import re
|
|
3
|
+
import time
|
|
4
|
+
from threading import Thread
|
|
5
|
+
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
from rich.table import Table
|
|
8
|
+
import readchar
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
from . import __version__
|
|
12
|
+
|
|
13
|
+
console = Console()
|
|
14
|
+
exit_flag = False # 按键退出标志
|
|
15
|
+
|
|
16
|
+
REFRESH_INTERVAL = 0.5
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def parse_rocm_smi():
|
|
20
|
+
"""解析 rocm-smi 输出为 GPU 信息列表"""
|
|
21
|
+
try:
|
|
22
|
+
output = subprocess.check_output(["rocm-smi"], text=True)
|
|
23
|
+
except Exception as e:
|
|
24
|
+
console.print(f"[red]Failed to run rocm-smi: {e}[/red]")
|
|
25
|
+
return []
|
|
26
|
+
|
|
27
|
+
gpus = []
|
|
28
|
+
lines = output.splitlines()
|
|
29
|
+
|
|
30
|
+
for line in lines:
|
|
31
|
+
line = line.strip()
|
|
32
|
+
if not line or line.startswith("=") or line.startswith("Device") or "Concise" in line:
|
|
33
|
+
continue
|
|
34
|
+
|
|
35
|
+
m_device = re.match(r'^(\d+)', line)
|
|
36
|
+
if not m_device:
|
|
37
|
+
continue
|
|
38
|
+
device = m_device.group(1)
|
|
39
|
+
|
|
40
|
+
percentages = re.findall(r'(\d+)%', line)
|
|
41
|
+
if len(percentages) >= 2:
|
|
42
|
+
vram = int(percentages[-2])
|
|
43
|
+
gpu_util = int(percentages[-1])
|
|
44
|
+
else:
|
|
45
|
+
vram = gpu_util = 0
|
|
46
|
+
|
|
47
|
+
temp_match = re.search(r'(\d+\.?\d*)°C', line)
|
|
48
|
+
temp = float(temp_match.group(1)) if temp_match else 0
|
|
49
|
+
|
|
50
|
+
power_match = re.search(r'(\d+\.?\d*)W', line)
|
|
51
|
+
power = float(power_match.group(1)) if power_match else 0
|
|
52
|
+
|
|
53
|
+
gpus.append({
|
|
54
|
+
"device": device,
|
|
55
|
+
"temp": temp,
|
|
56
|
+
"power": power,
|
|
57
|
+
"gpu_util": gpu_util,
|
|
58
|
+
"vram": vram
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return gpus
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def color_gpu_util(val):
|
|
65
|
+
if val >= 90:
|
|
66
|
+
return "red"
|
|
67
|
+
elif val >= 50:
|
|
68
|
+
return "yellow"
|
|
69
|
+
elif val > 0:
|
|
70
|
+
return "green"
|
|
71
|
+
else:
|
|
72
|
+
return "white"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def color_power(val):
|
|
76
|
+
if val > 600:
|
|
77
|
+
return "red"
|
|
78
|
+
elif val > 200:
|
|
79
|
+
return "yellow"
|
|
80
|
+
else:
|
|
81
|
+
return "green"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def color_vram(val):
|
|
85
|
+
if val > 90:
|
|
86
|
+
return "red"
|
|
87
|
+
elif val >= 50:
|
|
88
|
+
return "yellow"
|
|
89
|
+
elif val > 0:
|
|
90
|
+
return "green"
|
|
91
|
+
else:
|
|
92
|
+
return "white"
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def color_temp(val):
|
|
96
|
+
if val > 90:
|
|
97
|
+
return "red"
|
|
98
|
+
elif val >= 60:
|
|
99
|
+
return "yellow"
|
|
100
|
+
elif val >= 30:
|
|
101
|
+
return "green"
|
|
102
|
+
else:
|
|
103
|
+
return "white"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def display_gpus(gpus):
|
|
107
|
+
"""美化显示 GPU 表格"""
|
|
108
|
+
table = Table(title="AMD GPU Monitor (rocmtop)", box=None, expand=True)
|
|
109
|
+
table.add_column("Device", style="bold cyan")
|
|
110
|
+
table.add_column("Temp (°C)", justify="right")
|
|
111
|
+
table.add_column("Power (W)", justify="right")
|
|
112
|
+
table.add_column("GPU Util", justify="right", width=30)
|
|
113
|
+
table.add_column("VRAM %", justify="right")
|
|
114
|
+
|
|
115
|
+
bar_len = 20
|
|
116
|
+
|
|
117
|
+
for gpu in gpus:
|
|
118
|
+
temp_str = f"[{color_temp(gpu['temp'])}]{gpu['temp']}[/]"
|
|
119
|
+
power_str = f"[{color_power(gpu['power'])}]{gpu['power']}[/]"
|
|
120
|
+
|
|
121
|
+
filled_len = int(gpu['gpu_util'] / 100 * bar_len)
|
|
122
|
+
bar = "█" * filled_len + " " * (bar_len - filled_len)
|
|
123
|
+
gpu_cell = (
|
|
124
|
+
f"[{color_gpu_util(gpu['gpu_util'])}]"
|
|
125
|
+
f"{bar}{str(gpu['gpu_util']).rjust(30 - len(bar))}%[/]"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
vram_str = f"[{color_vram(gpu['vram'])}]{gpu['vram']}%[/]"
|
|
129
|
+
|
|
130
|
+
table.add_row(
|
|
131
|
+
gpu["device"],
|
|
132
|
+
temp_str,
|
|
133
|
+
power_str,
|
|
134
|
+
gpu_cell,
|
|
135
|
+
vram_str
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
console.clear()
|
|
139
|
+
console.print(table)
|
|
140
|
+
console.print("[bold magenta]Press 'q' or 'Q' to quit[/bold magenta]")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def key_listener():
|
|
144
|
+
global exit_flag
|
|
145
|
+
while True:
|
|
146
|
+
c = readchar.readkey()
|
|
147
|
+
if c in ("q", "Q"):
|
|
148
|
+
exit_flag = True
|
|
149
|
+
break
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def main():
|
|
153
|
+
parser = argparse.ArgumentParser()
|
|
154
|
+
parser.add_argument("--version", action="store_true", help="Show version and exit")
|
|
155
|
+
args = parser.parse_args()
|
|
156
|
+
|
|
157
|
+
if args.version:
|
|
158
|
+
print(f"rocmtop version {__version__}")
|
|
159
|
+
return
|
|
160
|
+
|
|
161
|
+
global exit_flag
|
|
162
|
+
|
|
163
|
+
Thread(target=key_listener, daemon=True).start()
|
|
164
|
+
|
|
165
|
+
while not exit_flag:
|
|
166
|
+
gpus = parse_rocm_smi()
|
|
167
|
+
if gpus:
|
|
168
|
+
display_gpus(gpus)
|
|
169
|
+
else:
|
|
170
|
+
console.print("[red]No GPU info found[/red]")
|
|
171
|
+
time.sleep(REFRESH_INTERVAL)
|
|
172
|
+
|
|
173
|
+
console.clear()
|
|
174
|
+
console.print("[bold green]Exiting rocmtop[/bold green]")
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rocmtop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight ROCm GPU monitoring tool (like nvidia-smi top)
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: rich
|
|
10
|
+
Requires-Dist: readchar
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# rocmtop
|
|
14
|
+
|
|
15
|
+
**rocmtop** 是一个轻量级的 ROCm GPU 监控工具,可以在终端动态展示 AMD 显卡的状态(温度、功率、GPU 利用率和显存占用),类似于 `nvidia-smi top`。
|
|
16
|
+
|
|
17
|
+
用户可以直接通过终端使用:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install rocmtop
|
|
21
|
+
|
|
22
|
+
rocmtop
|
|
23
|
+
````
|
|
24
|
+
|
|
25
|
+
## 功能特点
|
|
26
|
+
|
|
27
|
+
* 实时刷新 GPU 状态(默认 0.5 秒刷新间隔)
|
|
28
|
+
* 彩色显示 GPU 温度、功率、利用率和显存占用
|
|
29
|
+
* 进度条直观显示 GPU 利用率
|
|
30
|
+
* 按 `q` 或 `Q` 退出
|
|
31
|
+
* 轻量、易用,无依赖复杂库,仅依赖 `rich` 和 `readchar`
|
|
32
|
+
|
|
33
|
+
## 安装
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install rocmtop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使用
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
rocmtop
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> 注意:需要在支持 ROCm 的 AMD 显卡上使用,并安装 `rocm-smi` 工具。
|
|
46
|
+
|
|
47
|
+
## 作者
|
|
48
|
+
```
|
|
49
|
+
Ziyang Zhai (Liam)
|
|
50
|
+
|
|
51
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/rocmtop/__init__.py
|
|
5
|
+
src/rocmtop/cli.py
|
|
6
|
+
src/rocmtop.egg-info/PKG-INFO
|
|
7
|
+
src/rocmtop.egg-info/SOURCES.txt
|
|
8
|
+
src/rocmtop.egg-info/dependency_links.txt
|
|
9
|
+
src/rocmtop.egg-info/entry_points.txt
|
|
10
|
+
src/rocmtop.egg-info/requires.txt
|
|
11
|
+
src/rocmtop.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rocmtop
|