pmonitor 1.4.2__tar.gz → 1.4.4__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.
- {pmonitor-1.4.2 → pmonitor-1.4.4}/PKG-INFO +1 -1
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/mac_gpu.py +16 -11
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/monitor_pids.py +32 -12
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/run_monitor.py +1 -1
- {pmonitor-1.4.2 → pmonitor-1.4.4}/pmonitor.egg-info/PKG-INFO +1 -1
- {pmonitor-1.4.2 → pmonitor-1.4.4}/setup.py +1 -1
- {pmonitor-1.4.2 → pmonitor-1.4.4}/README.md +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/GpuMonitorLib.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/KernelBase.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/__init__.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/advapi32.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/bcrypt.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/kernel.appcore.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/kernel32.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/msvcirt.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/msvcp140.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/ntdll.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/pdh.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/rpcrt4.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/sechost.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/ucrtbased.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/vcruntime140.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/DLL/vcruntime140_1.dll +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/WinPidUtil.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/__init__.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/exec/GpuMonitor +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/exec/__init__.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/get_process_name.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/monitor_mac.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/monitor_win.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/monitor/sys_info.py +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/pmonitor.egg-info/SOURCES.txt +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/pmonitor.egg-info/dependency_links.txt +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/pmonitor.egg-info/entry_points.txt +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/pmonitor.egg-info/top_level.txt +0 -0
- {pmonitor-1.4.2 → pmonitor-1.4.4}/setup.cfg +0 -0
|
@@ -36,21 +36,26 @@ if platform.system() != 'Windows':
|
|
|
36
36
|
try:
|
|
37
37
|
gpu_info = accelerator_performance_statistics()
|
|
38
38
|
use_gpu_memory = 0
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
total_gpu_memory = 0
|
|
40
|
+
free_gpu_memory = 0
|
|
41
41
|
for key, value in gpu_info["PerformanceStatistics"].items():
|
|
42
|
-
if key == "In use system memory":
|
|
43
|
-
use_gpu_memory = int(value)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
elif key == "
|
|
49
|
-
|
|
42
|
+
if key == "In use system memory" or key == "gartUsedBytes":
|
|
43
|
+
use_gpu_memory = int(value)
|
|
44
|
+
elif key == "gartSizeBytes":
|
|
45
|
+
total_gpu_memory = int(value)
|
|
46
|
+
elif key == "gartFreeBytes":
|
|
47
|
+
free_gpu_memory = int(value)
|
|
48
|
+
elif key == "Alloc system memory":
|
|
49
|
+
total_gpu_memory = int(value)
|
|
50
50
|
# print('device usage', device_usage)
|
|
51
51
|
# use_gpu_memory = gpu_info["PerformanceStatistics"]["In use system memory"]
|
|
52
52
|
# total_gpu_memory = gpu_info["PerformanceStatistics"]["Alloc system memory"]
|
|
53
53
|
except Exception as e:
|
|
54
54
|
print(f"Mac端在arm64平台通过接口获取Gpu Memory失败:{e}")
|
|
55
55
|
use_gpu_memory = 0
|
|
56
|
-
|
|
56
|
+
total_gpu_memory = 0
|
|
57
|
+
free_gpu_memory = 0
|
|
58
|
+
if free_gpu_memory == 0:
|
|
59
|
+
free_gpu_memory = total_gpu_memory - use_gpu_memory
|
|
60
|
+
return round(use_gpu_memory / 1024 / 1024, 2), round(total_gpu_memory / 1024 / 1024, 2), round(
|
|
61
|
+
free_gpu_memory / 1024 / 1024, 2)
|
|
@@ -7,9 +7,8 @@ import asyncio
|
|
|
7
7
|
import platform
|
|
8
8
|
import ctypes
|
|
9
9
|
import os
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import re
|
|
10
|
+
from PyLibreHardwareMonitor.computer import Computer
|
|
11
|
+
|
|
13
12
|
if platform.system() != 'Windows':
|
|
14
13
|
from monitor.mac_gpu import get_gpu_memory
|
|
15
14
|
|
|
@@ -28,15 +27,18 @@ class PidsPerf:
|
|
|
28
27
|
minor_real_mem_sum = 0
|
|
29
28
|
minor_mem_percent_sum = 0
|
|
30
29
|
minor_thread_count_sum = 0
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
gpu_memory_percent_1 = 0
|
|
30
|
+
gpu_memory_usage = 0
|
|
31
|
+
gpu_memory_total = 0
|
|
32
|
+
gpu_memory_free = 0
|
|
35
33
|
current_pids = self.processUtil.get_children_pids(current_pid) # 获取所有子进程
|
|
36
34
|
current_pids.add(current_pid) # 将主进程及子进程添加到list中
|
|
37
35
|
pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
mem_info = psutil.virtual_memory()
|
|
38
|
+
mem_total = round(mem_info.total / 1024 / 1024, 2) # 总虚拟内存
|
|
39
|
+
mem_available = round(mem_info.available / 1024 / 1024, 2) # 剩余虚拟内存
|
|
40
|
+
|
|
41
|
+
gpu_memory_usage, gpu_memory_total, gpu_memory_free = get_gpu_memory()
|
|
40
42
|
for process in pids_process:
|
|
41
43
|
try:
|
|
42
44
|
cpu_percent = process.cpu_percent()
|
|
@@ -77,9 +79,10 @@ class PidsPerf:
|
|
|
77
79
|
io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
|
|
78
80
|
io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
|
|
79
81
|
disk_data = {'io read': io_read_bytes, 'io write': io_write_bytes}
|
|
80
|
-
gpu_data = {'gpu
|
|
81
|
-
'gpu
|
|
82
|
-
data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data
|
|
82
|
+
gpu_data = {'gpu memory usage': gpu_memory_usage, 'gpu memory total': gpu_memory_total,
|
|
83
|
+
'gpu memory free': gpu_memory_free}
|
|
84
|
+
data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data,
|
|
85
|
+
"memory_total": mem_total, "memory_available": mem_available}
|
|
83
86
|
json_data = json.dumps(data)
|
|
84
87
|
print(json_data)
|
|
85
88
|
sys.stdout.flush()
|
|
@@ -114,6 +117,9 @@ class PidsPerf:
|
|
|
114
117
|
gpu_monitor_dll = ctypes.CDLL(dll_path)
|
|
115
118
|
gpu_monitor_dll.GetGPUDataForProcess.argtypes = [ctypes.c_ulong]
|
|
116
119
|
gpu_monitor_dll.GetGPUDataForProcess.restype = ctypes.c_char_p
|
|
120
|
+
# 获取GPU物理内存
|
|
121
|
+
computer = Computer()
|
|
122
|
+
gpu_key = list(computer.gpu.keys())[0]
|
|
117
123
|
while True:
|
|
118
124
|
minor_cpu_sum = 0
|
|
119
125
|
minor_workSet_mem_sum = 0
|
|
@@ -145,6 +151,7 @@ class PidsPerf:
|
|
|
145
151
|
child_pids.add(p_pid) # app内所有pid
|
|
146
152
|
child_pids = {pid for pid in child_pids if psutil.pid_exists(pid)} # 移除不存在的进程
|
|
147
153
|
|
|
154
|
+
small_data = computer.gpu[gpu_key]['SmallData'] # 获取GPU物理内存信息
|
|
148
155
|
try:
|
|
149
156
|
new_pids_cpu_time_pre = {pid: pidWinPerf.get_process_cpu_time(pid) for pid in child_pids if
|
|
150
157
|
pid not in process_cpu_times_pre}
|
|
@@ -156,6 +163,8 @@ class PidsPerf:
|
|
|
156
163
|
|
|
157
164
|
# print('----------------------------------------------------------')
|
|
158
165
|
# print('pid', child_pids)
|
|
166
|
+
memory_total = round(psutil.virtual_memory().total / 1024 / 1024, 2)
|
|
167
|
+
memory_available = round(psutil.virtual_memory().available / 1024 / 1024, 2)
|
|
159
168
|
|
|
160
169
|
for pid in child_pids:
|
|
161
170
|
try:
|
|
@@ -241,8 +250,19 @@ class PidsPerf:
|
|
|
241
250
|
'gpu_System': round(minor_gpu_system_sum, 2),
|
|
242
251
|
'gpu_Committed': round(minor_gpu_committed_sum, 2),
|
|
243
252
|
'gpu_Usage': round(minor_gpu_percent_sum, 2)}
|
|
253
|
+
if 'GPU Memory Used' in small_data:
|
|
254
|
+
gpu_data = {'gpu memory usage': round(small_data['GPU Memory Used'], 2),
|
|
255
|
+
'gpu memory total': round(small_data['GPU Memory Total'], 2),
|
|
256
|
+
'gpu memory free': round(small_data['GPU Memory Free'], 2)}
|
|
257
|
+
else:
|
|
258
|
+
gpu_data = {'gpu memory usage': round(small_data['D3D Shared Memory Used'], 2),
|
|
259
|
+
'gpu memory total': round(small_data['D3D Shared Memory Total'], 2),
|
|
260
|
+
'gpu memory free': round(small_data['D3D Shared Memory Free'], 2)}
|
|
244
261
|
try:
|
|
245
|
-
data = {'main': main_data, 'other': other_data, 'disk': disk_data
|
|
262
|
+
data = {'main': main_data, 'other': other_data, 'disk': disk_data,
|
|
263
|
+
'gpu': gpu_data,
|
|
264
|
+
'memory_total': memory_total,
|
|
265
|
+
'memory_available': memory_available}
|
|
246
266
|
json_data = json.dumps(data)
|
|
247
267
|
print(json_data)
|
|
248
268
|
except UnboundLocalError:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|