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

Function quick_monitor

src/utils/gpu_monitor.py:310–339  ·  view source on GitHub ↗

快速启动监控的便捷函数 Args: gpu_index: GPU索引 interval: 监控间隔 unit: 单位 wait_for_input: 是否等待用户输入 Returns: float: 峰值显存使用量

(gpu_index=0, interval=0.5, unit='GB', wait_for_input=True)

Source from the content-addressed store, hash-verified

308
309# 快速使用函数
310def quick_monitor(gpu_index=0, interval=0.5, unit='GB', wait_for_input=True):
311 """
312 快速启动监控的便捷函数
313
314 Args:
315 gpu_index: GPU索引
316 interval: 监控间隔
317 unit: 单位
318 wait_for_input: 是否等待用户输入
319
320 Returns:
321 float: 峰值显存使用量
322 """
323 monitor = GPUMemoryMonitor(gpu_index=gpu_index, interval=interval, unit=unit)
324
325 try:
326 if monitor.start():
327 if wait_for_input:
328 print("按回车键停止监控...")
329 input()
330 else:
331 # 如果不等待用户输入,这里可以设置其他停止条件
332 # 例如:监控特定时间或直到某个条件满足
333 print("监控已启动,将在后台运行")
334 print("调用 monitor.stop() 来停止并获取结果")
335 return monitor
336 return None
337 except Exception as e:
338 print(f"监控失败: {e}")
339 return None
340
341
342# 测试代码

Callers

nothing calls this directly

Calls 2

startMethod · 0.95
GPUMemoryMonitorClass · 0.85

Tested by

no test coverage detected