From 5926e3289d1bfaef388773ed68d08994291e060c Mon Sep 17 00:00:00 2001 From: enkilee Date: Tue, 28 Feb 2023 23:57:22 +0800 Subject: [PATCH 1/4] add memory in other log --- mmengine/runner/log_processor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mmengine/runner/log_processor.py b/mmengine/runner/log_processor.py index 41fc3bc546..84c23eac74 100644 --- a/mmengine/runner/log_processor.py +++ b/mmengine/runner/log_processor.py @@ -271,6 +271,10 @@ def get_log_after_epoch(self, log_items.append(f'{name}: {val}') log_str += ' '.join(log_items) + # If cuda is available, the max memory occupied should be calculated. + if is_cuda_available(): + log_str += f'memory: {self._get_max_memory(runner)} ' + if with_non_scalar: tag.update(non_scalar_tag) return tag, log_str From 75d3ca5a6dc089d661a1de113f614741769b2532 Mon Sep 17 00:00:00 2001 From: enkilee Date: Mon, 6 Mar 2023 10:16:27 +0800 Subject: [PATCH 2/4] fix --- mmengine/runner/log_processor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mmengine/runner/log_processor.py b/mmengine/runner/log_processor.py index 84c23eac74..e719364f95 100644 --- a/mmengine/runner/log_processor.py +++ b/mmengine/runner/log_processor.py @@ -197,7 +197,9 @@ def get_log_after_iter(self, runner, batch_idx: int, # If cuda is available, the max memory occupied should be calculated. if is_cuda_available(): - log_str += f'memory: {self._get_max_memory(runner)} ' + max_memory = self._get_max_memory(runner) + log_str += f'memory: {max_memory} ' + tag['memory'] = max_memory # Loop left keys to fill `log_str`. if mode in ('train', 'val'): log_items = [] @@ -273,7 +275,9 @@ def get_log_after_epoch(self, # If cuda is available, the max memory occupied should be calculated. if is_cuda_available(): - log_str += f'memory: {self._get_max_memory(runner)} ' + max_memory = self._get_max_memory(runner) + log_str += f'memory: {max_memory} ' + tag['memory'] = max_memory if with_non_scalar: tag.update(non_scalar_tag) From 3884d2124cdd88d880af68b43eb90231a03be06c Mon Sep 17 00:00:00 2001 From: enkilee Date: Tue, 7 Mar 2023 08:49:44 +0800 Subject: [PATCH 3/4] fix --- mmengine/runner/log_processor.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mmengine/runner/log_processor.py b/mmengine/runner/log_processor.py index e719364f95..b443604a09 100644 --- a/mmengine/runner/log_processor.py +++ b/mmengine/runner/log_processor.py @@ -272,13 +272,6 @@ def get_log_after_epoch(self, val = f'\n{val}\n' log_items.append(f'{name}: {val}') log_str += ' '.join(log_items) - - # If cuda is available, the max memory occupied should be calculated. - if is_cuda_available(): - max_memory = self._get_max_memory(runner) - log_str += f'memory: {max_memory} ' - tag['memory'] = max_memory - if with_non_scalar: tag.update(non_scalar_tag) return tag, log_str From d2b0617a380befbb055fed66c8e6d5d3e77cdff3 Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 8 Mar 2023 12:57:27 +0800 Subject: [PATCH 4/4] keep empty line --- mmengine/runner/log_processor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mmengine/runner/log_processor.py b/mmengine/runner/log_processor.py index b443604a09..874a1ec127 100644 --- a/mmengine/runner/log_processor.py +++ b/mmengine/runner/log_processor.py @@ -272,6 +272,7 @@ def get_log_after_epoch(self, val = f'\n{val}\n' log_items.append(f'{name}: {val}') log_str += ' '.join(log_items) + if with_non_scalar: tag.update(non_scalar_tag) return tag, log_str