Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,23 @@ a+b=42
If using GPUtil to monitor GPUs during training, it may show 0% utilization. A way around this is to use a separate monitoring thread.
```python
import GPUtil
from threading import Thread
from threading import Thread, Event
import time

class Monitor(Thread):
def __init__(self, delay):
super(Monitor, self).__init__()
self.stopped = False
self.stopped = Event()
self.delay = delay # Time between calls to GPUtil
self.start()

def run(self):
while not self.stopped:
while not self.stopped.is_set():
GPUtil.showUtilization()
time.sleep(self.delay)

def stop(self):
self.stopped = True
self.stopped.set()

# Instantiate monitor with a 10-second delay between updates
monitor = Monitor(10)
Expand Down