[Jupyter] GPU 사용량 주기적으로 체크하는 코드
import GPUtil from threading import Thread import time class Monitor(Thread): def __init__(self, delay): super(Monitor, self).__init__() self.stopped = False self.delay = delay # Time between calls to GPUtil self.start() def run(self): while not self.stopped: GPUtil.showUtilization() time.sleep(self.delay) def stop(self): self.stopped = True monitor = Monitor(10) 멈추는 것은 STOP을 해주면 됨 monitor.stop()
2021.01.01