Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sg 644 upload big files properly on end #671

Merged
merged 8 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/super_gradients/common/sg_loggers/base_sg_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def add_scalars(self, tag_scalar_dict: dict, global_step: int = None):
self.tensorboard_writer.flush()

# WRITE THE EPOCH RESULTS TO LOG FILE
log_line = f"\nEpoch ({global_step}/{self.max_global_steps}) - "
log_line = f"\nEpoch {global_step} ({global_step+1}/{self.max_global_steps}) - "
for tag, value in tag_scalar_dict.items():
if isinstance(value, torch.Tensor):
value = value.item()
Expand Down Expand Up @@ -249,6 +249,9 @@ def add_file(self, file_name: str = None):

@multi_process_safe
def upload(self):
"""Upload the local tensorboard and log files to remote system."""
self.flush()

if self.save_tensorboard_remote:
self.model_checkpoints_data_interface.save_remote_tensorboard_event_files(self.experiment_name, self._local_dir)

Expand All @@ -259,12 +262,16 @@ def upload(self):
@multi_process_safe
def flush(self):
self.tensorboard_writer.flush()
ConsoleSink.flush()

@multi_process_safe
def close(self):
self.upload()

if self.system_monitor is not None:
self.system_monitor.close()
logger.info("[CLEANUP] - Successfully stopped system monitoring process")

self.tensorboard_writer.close()
if self.tensor_board_process is not None:
try:
Expand Down
4 changes: 1 addition & 3 deletions src/super_gradients/training/sg_trainer/sg_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,6 @@ def _train_epoch(self, epoch: int, silent_mode: bool = False) -> tuple:
):
break

if not self.ddp_silent_mode:
self.sg_logger.upload()

self.train_monitored_values = sg_trainer_utils.update_monitored_values_dict(
monitored_values_dict=self.train_monitored_values, new_values_dict=pbar_message_dict
)
Expand Down Expand Up @@ -1315,6 +1312,7 @@ def forward(self, inputs, targets):
if not self.ddp_silent_mode:
# SAVING AND LOGGING OCCURS ONLY IN THE MAIN PROCESS (IN CASES THERE ARE SEVERAL PROCESSES - DDP)
self._write_to_disk_operations(train_metrics_tuple, validation_results_tuple, inf_time, epoch, context)
self.sg_logger.upload()

# Evaluating the average model and removing snapshot averaging file if training is completed
if self.training_params.average_best_models:
Expand Down