Memory Usage

This commit is contained in:
Harle, Antoine (Contracteur) 2020-02-03 12:06:32 -05:00
parent fcd0217d54
commit cdeca24776

View file

@ -74,12 +74,12 @@ if __name__ == "__main__":
#Task to perform #Task to perform
tasks={ tasks={
#'classic', 'classic',
'aug_model' #'aug_model'
} }
#Parameters #Parameters
n_inner_iter = 1 n_inner_iter = 1
epochs = 10 epochs = 2
dataug_epoch_start=0 dataug_epoch_start=0
optim_param={ optim_param={
'Meta':{ 'Meta':{
@ -112,10 +112,16 @@ if __name__ == "__main__":
#log= train_classic_higher(model=model, epochs=epochs) #log= train_classic_higher(model=model, epochs=epochs)
exec_time=time.process_time() - t0 exec_time=time.process_time() - t0
max_cached = torch.cuda.max_memory_cached()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved()
#### ####
print('-'*9) print('-'*9)
times = [x["time"] for x in log] times = [x["time"] for x in log]
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times), exec_time), 'Optimizer': optim_param['Inner'], "Device": device_name, "Log": log} out = {"Accuracy": max([x["acc"] for x in log]),
"Time": (np.mean(times),np.std(times), exec_time),
'Optimizer': optim_param['Inner'],
"Device": device_name,
"Memory": max_cached,
"Log": log}
print(model_name,": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1]) print(model_name,": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1])
filename = "{}-{} epochs".format(model_name,epochs) filename = "{}-{} epochs".format(model_name,epochs)
with open("../res/log/%s.json" % filename, "w+") as f: with open("../res/log/%s.json" % filename, "w+") as f:
@ -156,10 +162,17 @@ if __name__ == "__main__":
save_sample_freq=None) save_sample_freq=None)
exec_time=time.process_time() - t0 exec_time=time.process_time() - t0
max_cached = torch.cuda.max_memory_cached()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved()
#### ####
print('-'*9) print('-'*9)
times = [x["time"] for x in log] times = [x["time"] for x in log]
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times), exec_time), 'Optimizer': optim_param, "Device": device_name, "Param_names": aug_model.TF_names(), "Log": log} out = {"Accuracy": max([x["acc"] for x in log]),
"Time": (np.mean(times),np.std(times), exec_time),
'Optimizer': optim_param,
"Device": device_name,
"Memory": max_cached,
"Param_names": aug_model.TF_names(),
"Log": log}
print(str(aug_model),": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1]) print(str(aug_model),": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1])
filename = "{}-{} epochs (dataug:{})- {} in_it".format(str(aug_model),epochs,dataug_epoch_start,n_inner_iter) filename = "{}-{} epochs (dataug:{})- {} in_it".format(str(aug_model),epochs,dataug_epoch_start,n_inner_iter)
with open("../res/log/%s.json" % filename, "w+") as f: with open("../res/log/%s.json" % filename, "w+") as f: