From 35996eafcf30e9c0858e2428ef92d4bd916c515c Mon Sep 17 00:00:00 2001 From: gzhcv Date: Tue, 24 Nov 2020 22:35:55 +0800 Subject: [PATCH] modified the permisson of gpu profiler file and directory --- mindspore/ccsrc/profiler/device/gpu/data_saver.cc | 2 +- mindspore/profiler/parser/step_trace_parser.py | 6 +++--- mindspore/profiler/profiling.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/profiler/device/gpu/data_saver.cc b/mindspore/ccsrc/profiler/device/gpu/data_saver.cc index 5ccb57cc24..fb74820538 100644 --- a/mindspore/ccsrc/profiler/device/gpu/data_saver.cc +++ b/mindspore/ccsrc/profiler/device/gpu/data_saver.cc @@ -310,7 +310,7 @@ void DataSaver::WriteStepTrace(const std::string &saver_base_dir) { void DataSaver::SetStepTraceOpName(ProfilingTraceInfo trace_op_name) { step_trace_op_name = trace_op_name; } void DataSaver::ChangeFileMode(const std::string &file_path) { - if (chmod(common::SafeCStr(file_path), S_IRUSR | S_IWUSR) == -1) { + if (chmod(common::SafeCStr(file_path), S_IRUSR) == -1) { MS_LOG(WARNING) << "Modify file:" << file_path << " to rw fail."; return; } diff --git a/mindspore/profiler/parser/step_trace_parser.py b/mindspore/profiler/parser/step_trace_parser.py index ddad5367cb..22875fb6ad 100644 --- a/mindspore/profiler/parser/step_trace_parser.py +++ b/mindspore/profiler/parser/step_trace_parser.py @@ -329,7 +329,7 @@ class BaseStepTraceParser: csv_writer.writerow(self._header) for row_data in self._result: csv_writer.writerow(row_data) - os.chmod(self._output_path, stat.S_IREAD) + os.chmod(self._output_path, stat.S_IRUSR) class GpuStepTraceParser(BaseStepTraceParser): @@ -363,7 +363,7 @@ class GpuStepTraceParser(BaseStepTraceParser): try: with open(output_path, 'w') as json_file: json.dump(points, json_file) - os.chmod(output_path, stat.S_IREAD) + os.chmod(output_path, stat.S_IRUSR) except (IOError, OSError) as err: log.warning('Failed to save point info. %s', err) raise ProfilerIOException @@ -463,7 +463,7 @@ class AscendStepTraceParser(BaseStepTraceParser): try: with open(output_path, 'w') as json_file: json.dump(points, json_file) - os.chmod(output_path, stat.S_IREAD) + os.chmod(output_path, stat.S_IRUSR) except (IOError, OSError) as err: log.warning('Failed to save point info. %s', err) raise ProfilerIOException diff --git a/mindspore/profiler/profiling.py b/mindspore/profiler/profiling.py index 0e84dfa85a..3322f8a1a9 100644 --- a/mindspore/profiler/profiling.py +++ b/mindspore/profiler/profiling.py @@ -14,6 +14,7 @@ # ============================================================================ """Profiling api file.""" import os +import stat import time from enum import Enum @@ -84,6 +85,7 @@ class Profiler: self._output_path = os.path.join(self._output_path, "profiler") if not os.path.exists(self._output_path): os.makedirs(self._output_path, exist_ok=True) + os.chmod(self._output_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) else: logger.warning("The target dir already exists. " "There may be some old profiling data, and they will be rewrote in the end.")