728x90
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()'분석 Python > 구현 및 자료' 카테고리의 다른 글
| [Python] itertools (0) | 2021.01.01 |
|---|---|
| [Python] 적절한 샘플 사이즈를 찾아주는 코드 (0) | 2021.01.01 |
| [Python] Wordcloud Example (0) | 2020.12.31 |
| [TIP] Class에 사전(dict)으로 property 추가하는 법 (0) | 2020.12.18 |
| [변수 선택] Genetic Algorithm를 이용 (Python) (0) | 2020.10.07 |