MCPcopy Create free account
hub / github.com/EverMind-AI/MSA / _monitor_loop

Method _monitor_loop

src/utils/gpu_monitor.py:74–98  ·  view source on GitHub ↗

监控循环,运行在单独线程中

(self)

Source from the content-addressed store, hash-verified

72 return 0
73
74 def _monitor_loop(self):
75 """监控循环,运行在单独线程中"""
76 # print(f"开始监控 GPU {self.gpu_index} ({self.gpu_name})")
77 # print(f"监控间隔: {self.interval}秒")
78 # print(f"单位: {self.unit}")
79 # print("按回车键停止监控...\n")
80
81 try:
82 while self._running:
83 # 获取当前显存使用量
84 current_usage = self._get_current_usage()
85
86 # 更新峰值
87 with self._lock:
88 if current_usage > self.peak_memory_usage:
89 self.peak_memory_usage = current_usage
90
91 # 等待下一个监控周期
92 time.sleep(self.interval)
93
94 except Exception as e:
95 print(f"监控线程出错: {e}")
96 finally:
97 # print(f"GPU {self.gpu_index} 监控线程结束")
98 pass
99
100 def start(self):
101 """

Callers

nothing calls this directly

Calls 1

_get_current_usageMethod · 0.95

Tested by

no test coverage detected