1.运行时间:
f = open("check_time_"+self.args.color+".txt", "a")
if i%20==0:
f.write("when in iteration: "+ str(i)+'\n')
line1_time = time.time()
……
line2_time = time.time()
if i%20==0:
f.write("time of preprocessing step"+str(line2_time-line1_time)+'\n')
……
f.close()
2.占用内存:
file.write(f"scores Current GPU memory allocated: {torch.cuda.memory_allocated() / 1024**2:.2f} MB")
file.write(f"Max GPU memory allocated: {torch.cuda.max_memory_allocated() / 1024**2:.2f} MB")