mirror of
https://github.com/AntoineHX/smart_augmentation.git
synced 2025-05-04 04:00:46 +02:00
Sauvegarde both mesure memoire
This commit is contained in:
parent
7d5aa7c6fb
commit
65e67addf6
2 changed files with 14 additions and 8 deletions
|
@ -97,6 +97,7 @@ if __name__ == "__main__":
|
||||||
for m_setup in mag_setup:
|
for m_setup in mag_setup:
|
||||||
|
|
||||||
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
||||||
|
torch.cuda.reset_max_memory_cached() #reset_peak_stats
|
||||||
t0 = time.perf_counter()
|
t0 = time.perf_counter()
|
||||||
|
|
||||||
model = getattr(model_type, model_name)(pretrained=False)
|
model = getattr(model_type, model_name)(pretrained=False)
|
||||||
|
@ -126,7 +127,8 @@ if __name__ == "__main__":
|
||||||
save_sample_freq=None)
|
save_sample_freq=None)
|
||||||
|
|
||||||
exec_time=time.perf_counter() - t0
|
exec_time=time.perf_counter() - t0
|
||||||
max_cached = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
max_allocated = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0)
|
||||||
|
max_cached = torch.cuda.max_memory_cached()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
||||||
####
|
####
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
times = [x["time"] for x in log]
|
times = [x["time"] for x in log]
|
||||||
|
@ -134,7 +136,7 @@ if __name__ == "__main__":
|
||||||
"Time": (np.mean(times),np.std(times), exec_time),
|
"Time": (np.mean(times),np.std(times), exec_time),
|
||||||
'Optimizer': optim_param,
|
'Optimizer': optim_param,
|
||||||
"Device": device_name,
|
"Device": device_name,
|
||||||
"Memory": max_cached,
|
"Memory": [max_allocated, max_cached],
|
||||||
"Param_names": aug_model.TF_names(),
|
"Param_names": aug_model.TF_names(),
|
||||||
"Log": log}
|
"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])
|
||||||
|
@ -155,6 +157,7 @@ if __name__ == "__main__":
|
||||||
for model_name in model_list[model_type]:
|
for model_name in model_list[model_type]:
|
||||||
for run in range(nb_run):
|
for run in range(nb_run):
|
||||||
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
||||||
|
torch.cuda.reset_max_memory_cached() #reset_peak_stats
|
||||||
t0 = time.perf_counter()
|
t0 = time.perf_counter()
|
||||||
|
|
||||||
model = getattr(model_type, model_name)(pretrained=False).to(device)
|
model = getattr(model_type, model_name)(pretrained=False).to(device)
|
||||||
|
@ -164,7 +167,8 @@ if __name__ == "__main__":
|
||||||
log= train_classic(model=model, opt_param=optim_param, epochs=epochs, print_freq=epochs/4)
|
log= train_classic(model=model, opt_param=optim_param, epochs=epochs, print_freq=epochs/4)
|
||||||
|
|
||||||
exec_time=time.perf_counter() - t0
|
exec_time=time.perf_counter() - t0
|
||||||
max_cached = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
max_allocated = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0)
|
||||||
|
max_cached = torch.cuda.max_memory_cached()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
||||||
####
|
####
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
times = [x["time"] for x in log]
|
times = [x["time"] for x in log]
|
||||||
|
@ -172,7 +176,7 @@ if __name__ == "__main__":
|
||||||
"Time": (np.mean(times),np.std(times), exec_time),
|
"Time": (np.mean(times),np.std(times), exec_time),
|
||||||
'Optimizer': optim_param,
|
'Optimizer': optim_param,
|
||||||
"Device": device_name,
|
"Device": device_name,
|
||||||
"Memory": max_cached,
|
"Memory": [max_allocated, max_cached],
|
||||||
#"Rand_Aug": rand_aug,
|
#"Rand_Aug": rand_aug,
|
||||||
"Log": log}
|
"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])
|
||||||
|
|
|
@ -82,7 +82,7 @@ if __name__ == "__main__":
|
||||||
}
|
}
|
||||||
#Parameters
|
#Parameters
|
||||||
n_inner_iter = 1
|
n_inner_iter = 1
|
||||||
epochs = 150
|
epochs = 2
|
||||||
dataug_epoch_start=0
|
dataug_epoch_start=0
|
||||||
optim_param={
|
optim_param={
|
||||||
'Meta':{
|
'Meta':{
|
||||||
|
@ -147,6 +147,7 @@ if __name__ == "__main__":
|
||||||
#### Augmented Model ####
|
#### Augmented Model ####
|
||||||
if 'aug_model' in tasks:
|
if 'aug_model' in tasks:
|
||||||
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
torch.cuda.reset_max_memory_allocated() #reset_peak_stats
|
||||||
|
torch.cuda.reset_max_memory_cached() #reset_peak_stats
|
||||||
t0 = time.perf_counter()
|
t0 = time.perf_counter()
|
||||||
|
|
||||||
tf_dict = {k: TF.TF_dict[k] for k in tf_names}
|
tf_dict = {k: TF.TF_dict[k] for k in tf_names}
|
||||||
|
@ -163,10 +164,11 @@ if __name__ == "__main__":
|
||||||
print_freq=1,
|
print_freq=1,
|
||||||
unsup_loss=1,
|
unsup_loss=1,
|
||||||
hp_opt=False,
|
hp_opt=False,
|
||||||
save_sample_freq=1)
|
save_sample_freq=None)
|
||||||
|
|
||||||
exec_time=time.perf_counter() - t0
|
exec_time=time.perf_counter() - t0
|
||||||
max_cached = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
max_allocated = torch.cuda.max_memory_allocated()/(1024.0 * 1024.0)
|
||||||
|
max_cached = torch.cuda.max_memory_cached()/(1024.0 * 1024.0) #torch.cuda.max_memory_reserved() #MB
|
||||||
####
|
####
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
times = [x["time"] for x in log]
|
times = [x["time"] for x in log]
|
||||||
|
@ -174,7 +176,7 @@ if __name__ == "__main__":
|
||||||
"Time": (np.mean(times),np.std(times), exec_time),
|
"Time": (np.mean(times),np.std(times), exec_time),
|
||||||
'Optimizer': optim_param,
|
'Optimizer': optim_param,
|
||||||
"Device": device_name,
|
"Device": device_name,
|
||||||
"Memory": max_cached,
|
"Memory": [max_allocated, max_cached],
|
||||||
"Param_names": aug_model.TF_names(),
|
"Param_names": aug_model.TF_names(),
|
||||||
"Log": log}
|
"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])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue