From c86ffe05ee05894fc1534fca303da527bdc1a3a8 Mon Sep 17 00:00:00 2001 From: liuchuting Date: Tue, 22 Mar 2022 09:48:53 +0800 Subject: [PATCH] If the GPU memory is set to true, the test case fails and add warning about profiler does not support training and reasoning at the same time. --- mindspore/python/mindspore/profiler/profiling.py | 11 ++--------- tests/st/profiler/test_profiler.py | 10 +++++----- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/mindspore/python/mindspore/profiler/profiling.py b/mindspore/python/mindspore/profiler/profiling.py index 59fdd259865..051432ecd83 100644 --- a/mindspore/python/mindspore/profiler/profiling.py +++ b/mindspore/python/mindspore/profiler/profiling.py @@ -685,15 +685,8 @@ class Profiler: logger.warning(err.message) logger.warning( - '\nMemory Usage is not supported on GPU currently.\n' - 'Please running on Ascend if you would like to see memory analysis, ' - 'otherwise, this warning can be ignored.' - ) - - logger.warning( - '\nProfile communication is not supported on GPU currently.\n' - 'Please running on Ascend if you would like to see cluster communication analysis, ' - 'otherwise, this warning can be ignored.' + '\nThe training and inference process does not support profiler currently, ' + 'only individual training or inference is supported.' ) def _get_step_reduce_op_type(self): diff --git a/tests/st/profiler/test_profiler.py b/tests/st/profiler/test_profiler.py index 87195f92e52..af0fd1532bb 100644 --- a/tests/st/profiler/test_profiler.py +++ b/tests/st/profiler/test_profiler.py @@ -151,7 +151,7 @@ class TestProfiler: def test_cpu_profiler(self): if sys.platform != 'linux': return - self._train_with_profiler(device_target="CPU") + self._train_with_profiler(device_target="CPU", profile_memory=False) self._check_cpu_profiling_file() @pytest.mark.level1 @@ -159,7 +159,7 @@ class TestProfiler: @pytest.mark.env_onecard @security_off_wrap def test_gpu_profiler(self): - self._train_with_profiler(device_target="GPU") + self._train_with_profiler(device_target="GPU", profile_memory=False) self._check_gpu_profiling_file() @pytest.mark.level0 @@ -168,12 +168,12 @@ class TestProfiler: @pytest.mark.env_onecard @security_off_wrap def test_ascend_profiler(self): - self._train_with_profiler(device_target="Ascend") + self._train_with_profiler(device_target="Ascend", profile_memory=True) self._check_d_profiling_file() - def _train_with_profiler(self, device_target): + def _train_with_profiler(self, device_target, profile_memory): context.set_context(mode=context.GRAPH_MODE, device_target=device_target) - profiler = Profiler(profile_memory=True, output_path='data') + profiler = Profiler(profile_memory=profile_memory, output_path='data') profiler_name = os.listdir(os.path.join(os.getcwd(), 'data'))[0] self.profiler_path = os.path.join(os.getcwd(), f'data/{profiler_name}/') ds_train = create_dataset(os.path.join(self.mnist_path, "train"))