diff --git a/mindinsight/profiler/profiling.py b/mindinsight/profiler/profiling.py index 5bc3e15918ff414d5965033b5425b2044ac31b92..b7385f0294d67c57e478e75e5448a1e382c8a544 100644 --- a/mindinsight/profiler/profiling.py +++ b/mindinsight/profiler/profiling.py @@ -81,6 +81,15 @@ class Profiler: os.environ['PROFILING_MODE'] = 'true' os.environ['PROFILING_OPTIONS'] = 'training_trace:task_trace' + # use context interface to open profiling, for the new mindspore version(after 2020.5.21) + try: + import mindspore.context as context + context.set_context(enable_profiling=True, profiling_options="training_trace:task_trace") + except ImportError: + logger.error("Profiling: fail to import context from mindspore.") + except ValueError as err: + logger.err("Profiling: fail to set context", err.message) + os.environ['AICPU_PROFILING_MODE'] = 'true' os.environ['PROFILING_DIR'] = str(self._container_path) self._subgraph = check_subgraph(subgraph)