-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_results.py
85 lines (67 loc) · 1.95 KB
/
run_results.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import numpy as np
import os
import copy
import threading
import argparse
from results import get_runs
##############################################
parser = argparse.ArgumentParser()
parser.add_argument('--print', type=int, default=0)
cmd_args = parser.parse_args()
##############################################
num_gpus = 4
counter = 0
def run_command(param):
global num_gpus, counter
if num_gpus == 0:
gpu = -1
else:
gpu = counter % num_gpus
counter = counter + 1
name = '%s_%f_%f_%s_%f_%f_%d_%d_%s' % (
param['benchmark'],
param['lr'],
param['eps'],
param['act'],
param['bias'],
param['dropout'],
param['dfa'],
param['sparse'],
param['init']
)
cmd = "python36 %s --gpu %d --epochs %d --batch_size %d --lr %f --eps %f --act %s --bias %f --dropout %f --dfa %d --sparse %d --rank %d --init %s --save %d --name %s" % (
param['benchmark'],
gpu,
param['epochs'],
param['batch_size'],
param['lr'],
param['eps'],
param['act'],
param['bias'],
param['dropout'],
param['dfa'],
param['sparse'],
param['rank'],
param['init'],
1,
name
)
if cmd_args.print:
print (cmd)
else:
os.system(cmd)
return
##############################################
runs = get_runs()
##############################################
num_runs = len(runs)
parallel_runs = num_gpus
for run in range(0, num_runs, parallel_runs):
threads = []
for parallel_run in range( min(parallel_runs, num_runs - run)):
args = runs[run + parallel_run]
t = threading.Thread(target=run_command, args=(args,))
threads.append(t)
t.start()
for t in threads:
t.join()