Start monitoring GPU metrics in a separate process.
(self)
| 245 | connection.close() |
| 246 | |
| 247 | def start(self): |
| 248 | """Start monitoring GPU metrics in a separate process.""" |
| 249 | if self.gpu_type is None: |
| 250 | self.logger.debug("GPU monitoring skipped (no supported GPU)") |
| 251 | return |
| 252 | |
| 253 | self.child_connection, self.parent_connection = Pipe() |
| 254 | self.process = Process( |
| 255 | target=GPUMonitor._monitor_worker, |
| 256 | args=(self.gpu_type, self.sample_interval_sec, self.child_connection), |
| 257 | daemon=True, |
| 258 | ) |
| 259 | self.process.start() |
| 260 | |
| 261 | # Wait for worker to signal ready |
| 262 | if self.process.is_alive(): |
| 263 | self.parent_connection.recv() |
| 264 | self.logger.debug("GPU monitoring started (multiprocessing)") |
| 265 | |
| 266 | def stop_and_collect(self) -> GPURawMetrics: |
| 267 | """Stop monitoring and return collected metrics.""" |