Removed imports for old config files
This commit is contained in:
parent
7fa9a14303
commit
a2300273a5
|
@ -9,7 +9,6 @@ from torch.nn import Parameter
|
|||
|
||||
import utils
|
||||
from metrics import calculate_kl as KL_DIV
|
||||
import config_bayesian as cfg
|
||||
from ..misc import ModuleWrapper
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ from torch.nn import Parameter
|
|||
|
||||
import utils
|
||||
from metrics import calculate_kl as KL_DIV
|
||||
import config_bayesian as cfg
|
||||
from ..misc import ModuleWrapper
|
||||
|
||||
|
||||
|
|
117
run_service.py
117
run_service.py
|
@ -1,8 +1,43 @@
|
|||
import psutil
|
||||
import pickle
|
||||
import arguments
|
||||
from time import sleep
|
||||
import subprocess as sub
|
||||
from arguments import makeArguments
|
||||
|
||||
|
||||
def kill(proc_pid):
|
||||
process = psutil.Process(proc_pid)
|
||||
for proc in process.children(recursive=True):
|
||||
proc.kill()
|
||||
process.kill()
|
||||
|
||||
cfg = {
|
||||
"model": {"net_type": None, "type": None, "size": None, "layer_type": "lrt",
|
||||
"activation_type": "softplus", "priors": {
|
||||
'prior_mu': 0,
|
||||
'prior_sigma': 0.1,
|
||||
'posterior_mu_initial': (0, 0.1), # (mean, std) normal_
|
||||
'posterior_rho_initial': (-5, 0.1), # (mean, std) normal_
|
||||
},
|
||||
"n_epochs": 3,
|
||||
"sens": 1e-9,
|
||||
"energy_thrs": 10000,
|
||||
"acc_thrs": 0.99,
|
||||
"lr": 0.001,
|
||||
"num_workers": 4,
|
||||
"valid_size": 0.2,
|
||||
"batch_size": 256,
|
||||
"train_ens": 1,
|
||||
"valid_ens": 1,
|
||||
"beta_type": 0.1, # 'Blundell', 'Standard', etc. Use float for const value
|
||||
},
|
||||
"data": None,
|
||||
"stopping_crit": None,
|
||||
"save": None,
|
||||
"pickle_path": None,
|
||||
}
|
||||
|
||||
args = makeArguments(arguments.all_args)
|
||||
|
||||
check = list(args.values())
|
||||
|
@ -11,36 +46,57 @@ if all(v is None for v in check):
|
|||
elif None in check:
|
||||
if args['f'] is not None:
|
||||
cmd = ["python", "main_frequentist.py"]
|
||||
cfg["model"]["type"] = "frequentist"
|
||||
elif args['b'] is not None:
|
||||
cmd = ["python", "main_bayesian.py"]
|
||||
cfg["model"]["type"] = "bayesian"
|
||||
else:
|
||||
raise Exception("Only one argument allowed")
|
||||
|
||||
|
||||
wide = args["f"] or args["b"]
|
||||
|
||||
with open("tmp", "w") as file:
|
||||
file.write(str(wide))
|
||||
cfg["model"]["size"] = wide
|
||||
cfg["data"] = args["dataset"]
|
||||
cfg["model"]["net_type"] = args["net_type"]
|
||||
|
||||
#with open("tmp", "w") as file:
|
||||
# file.write(str(wide))
|
||||
|
||||
if args['EarlyStopping']:
|
||||
with open("stp", "w") as file:
|
||||
file.write('2')
|
||||
cfg["stopping_crit"] = 2
|
||||
#with open("stp", "w") as file:
|
||||
# file.write('2')
|
||||
elif args['EnergyBound']:
|
||||
with open("stp", "w") as file:
|
||||
file.write('3')
|
||||
cfg["stopping_crit"] = 3
|
||||
#with open("stp", "w") as file:
|
||||
# file.write('3')
|
||||
elif args['AccuracyBound']:
|
||||
with open("stp", "w") as file:
|
||||
file.write('4')
|
||||
cfg["stopping_crit"] = 4
|
||||
#with open("stp", "w") as file:
|
||||
# file.write('4')
|
||||
else:
|
||||
with open("stp", "w") as file:
|
||||
file.write('1')
|
||||
cfg["stopping_crit"] = 1
|
||||
#with open("stp", "w") as file:
|
||||
# file.write('1')
|
||||
|
||||
if args['Save']:
|
||||
with open("sav", "w") as file:
|
||||
file.write('1')
|
||||
cfg["save"] = 1
|
||||
#with open("sav", "w") as file:
|
||||
# file.write('1')
|
||||
else:
|
||||
with open("sav", "w") as file:
|
||||
file.write('0')
|
||||
cfg["save"] = 0
|
||||
#with open("sav", "w") as file:
|
||||
# file.write('0')
|
||||
|
||||
|
||||
cfg["pickle_path"] = "{}_wattdata_{}.pkl".format(cfg["model"]["type"],cfg["model"]["size"])
|
||||
|
||||
with open("configuration.pkl", "wb") as f:
|
||||
pickle.dump(cfg, f)
|
||||
|
||||
#print(args)
|
||||
print(cfg)
|
||||
|
||||
sleep(3)
|
||||
|
||||
|
@ -48,17 +104,19 @@ sleep(3)
|
|||
if cmd[1] == "main_frequentist.py":
|
||||
cmd2 = ["./cpu_watt.sh", "freq_{}_cpu_watts".format(wide)]
|
||||
cmd3 = ["./mem_free.sh", "freq_{}_ram_use".format(wide)]
|
||||
with open("frq", "w") as file:
|
||||
file.write(str(1))
|
||||
with open("bay", "w") as file:
|
||||
file.write(str(0))
|
||||
cmd4 = ["./radeontop.sh", "freq_{}_flop_app".format(wide)]
|
||||
#with open("frq", "w") as file:
|
||||
# file.write(str(1))
|
||||
#with open("bay", "w") as file:
|
||||
# file.write(str(0))
|
||||
elif cmd[1] == "main_bayesian.py":
|
||||
cmd2 = ["./cpu_watt.sh", "bayes_{}_cpu_watts".format(wide)]
|
||||
cmd3 = ["./mem_free.sh", "bayes_{}_ram_use".format(wide)]
|
||||
with open("bay", "w") as file:
|
||||
file.write(str(1))
|
||||
with open("frq", "w") as file:
|
||||
file.write(str(0))
|
||||
cmd4 = ["./radeontop.sh", "bayes_{}_flop_app".format(wide)]
|
||||
#with open("bay", "w") as file:
|
||||
# file.write(str(1))
|
||||
#with open("frq", "w") as file:
|
||||
# file.write(str(0))
|
||||
|
||||
|
||||
path = sub.check_output(['pwd'])
|
||||
|
@ -67,6 +125,7 @@ path = path.replace('\n', '')
|
|||
|
||||
startWattCounter = 'python ' + path + '/amd_sample_draw.py'
|
||||
|
||||
|
||||
#test = startNODE.split()
|
||||
#test.append(pythonEnd)
|
||||
#test.append(pythonEnd2)
|
||||
|
@ -77,14 +136,18 @@ startWattCounter = 'python ' + path + '/amd_sample_draw.py'
|
|||
#print(startWattCounter)
|
||||
|
||||
p1 = sub.Popen(cmd)
|
||||
#p2 = sub.Popen(startWattCounter.split(),stdin=sub.PIPE,stdout=sub.PIPE, stderr=sub.PIPE)
|
||||
p2 = sub.Popen(startWattCounter.split())
|
||||
p3 = sub.Popen(cmd2)
|
||||
p4 = sub.Popen(cmd3)
|
||||
p3 = sub.Popen(cmd2,stdin=sub.PIPE,stdout=sub.PIPE, stderr=sub.PIPE)
|
||||
p4 = sub.Popen(cmd3,stdin=sub.PIPE,stdout=sub.PIPE, stderr=sub.PIPE)
|
||||
p5 = sub.Popen(cmd4,stdin=sub.PIPE,stdout=sub.PIPE, stderr=sub.PIPE)
|
||||
|
||||
retcode = p1.wait()
|
||||
print("Return code: {}".format(retcode))
|
||||
|
||||
p1.kill()
|
||||
p2.kill()
|
||||
p3.kill()
|
||||
p4.kill()
|
||||
kill(p2.pid)
|
||||
kill(p3.pid)
|
||||
kill(p4.pid)
|
||||
kill(p5.pid)
|
||||
|
||||
|
|
Loading…
Reference in New Issue