close writer in after_run

pull/1489/head
ly015 2021-10-29 12:38:27 +08:00 committed by Wenwei Zhang
parent 9071202fde
commit a68d28c9f8
1 changed files with 4 additions and 4 deletions
mmcv/runner/hooks/logger

View File

@ -100,6 +100,10 @@ class PaviLoggerHook(LoggerHook):
snapshot_file_path=ckpt_path,
iteration=iteration)
# flush the buffer and send a task ending signal to Pavi
if hasattr(self, 'writer'):
self.writer.close()
@master_only
def before_epoch(self, runner):
if runner.epoch == 0 and self.add_graph:
@ -112,7 +116,3 @@ class PaviLoggerHook(LoggerHook):
image = data[self.img_key][0:1].to(device)
with torch.no_grad():
self.writer.add_graph(_model, image)
def __del__(self):
if hasattr(self, 'writer'):
self.writer.close()