forked from claws-lab/jodie
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck.py
37 lines (30 loc) · 935 Bytes
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import subprocess
import time
from datetime import datetime
counter = 0
while True:
time.sleep(5)
stream = os.popen('nvidia-smi')
output = stream.read()
lines = output.split('\n')
gpu_used = {'0': 0, '1': 0}
for line in reversed(lines[:-2]):
words = line.split()
if len(words) <= 2:
break
gpu_used[words[1]] += int(words[5][:-3])
if counter % 60 == 0:
print(datetime.now(), gpu_used)
counter += 1
found = False
for key, value in gpu_used.items():
if value < 6000:
found = True
with open('stdout-%s.txt' % counter, 'w') as f:
process = subprocess.Popen(['/home/eloghmani/myjodie/evaluate_all_epochs.sh', 'lastfm', 'interaction', key],
stdout=f,
stderr=f)
break
if found:
break