2================================================================================
3@file: gpu_power_monitor.py
4@brief: Monitors
and prints real-time GPU power usage
with timestamps.
5@author: Mingyu Yang (yang926
@yonsei.ac.kr), School of Mathematics
and Computing (Computational Science
and Engineering), Yonsei University
6 Oh-Kyoung Kwon (okkwon
@kisti.re.kr), Korea Institute of Science
and Technology Information
7 Jung-Il Choi (jic
@yonsei.ac.kr), School of Mathematics
and Computing (Computational Science
and Engineering), Yonsei University
10@copyright: Copyright (c) 2023 Mingyu Yang, Oh-Kyoung Kwon, Jung-Il Choi. All rights reserved.
11@license: This project
is released under the terms of the MIT License (see LICENSE file).
12================================================================================
16import matplotlib.pyplot as plt
20from datetime import datetime, timedelta
22# Initialize NVIDIA Management Library (NVML)
25# Get handle for the first available GPU
26handle = pynvml.nvmlDeviceGetHandleByIndex(0)
28# Set measurement interval (in seconds)
29measurement_interval = 0.01
35 current_datetime = now.strftime(
"%Y%m%d %H:%M:%S.%f")
37 measure = pynvml.nvmlDeviceGetPowerUsage(handle) / mW_to_W
39 print(
"time : ", current_datetime, measure)