forked from mindspore-Ecosystem/mindspore
!8975 Modify the permisson of gpu profiler file and directory
From: @gzhcv Reviewed-by: @wangyue01,@yuximiao Signed-off-by: @yuximiao
This commit is contained in:
commit
c84253d9cd
|
@ -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::SetStepTraceOpName(ProfilingTraceInfo trace_op_name) { step_trace_op_name = trace_op_name; }
|
||||||
|
|
||||||
void DataSaver::ChangeFileMode(const std::string &file_path) {
|
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.";
|
MS_LOG(WARNING) << "Modify file:" << file_path << " to rw fail.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ class BaseStepTraceParser:
|
||||||
csv_writer.writerow(self._header)
|
csv_writer.writerow(self._header)
|
||||||
for row_data in self._result:
|
for row_data in self._result:
|
||||||
csv_writer.writerow(row_data)
|
csv_writer.writerow(row_data)
|
||||||
os.chmod(self._output_path, stat.S_IREAD)
|
os.chmod(self._output_path, stat.S_IRUSR)
|
||||||
|
|
||||||
|
|
||||||
class GpuStepTraceParser(BaseStepTraceParser):
|
class GpuStepTraceParser(BaseStepTraceParser):
|
||||||
|
@ -363,7 +363,7 @@ class GpuStepTraceParser(BaseStepTraceParser):
|
||||||
try:
|
try:
|
||||||
with open(output_path, 'w') as json_file:
|
with open(output_path, 'w') as json_file:
|
||||||
json.dump(points, 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:
|
except (IOError, OSError) as err:
|
||||||
log.warning('Failed to save point info. %s', err)
|
log.warning('Failed to save point info. %s', err)
|
||||||
raise ProfilerIOException
|
raise ProfilerIOException
|
||||||
|
@ -463,7 +463,7 @@ class AscendStepTraceParser(BaseStepTraceParser):
|
||||||
try:
|
try:
|
||||||
with open(output_path, 'w') as json_file:
|
with open(output_path, 'w') as json_file:
|
||||||
json.dump(points, 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:
|
except (IOError, OSError) as err:
|
||||||
log.warning('Failed to save point info. %s', err)
|
log.warning('Failed to save point info. %s', err)
|
||||||
raise ProfilerIOException
|
raise ProfilerIOException
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
"""Profiling api file."""
|
"""Profiling api file."""
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
import time
|
import time
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ class Profiler:
|
||||||
self._output_path = os.path.join(self._output_path, "profiler")
|
self._output_path = os.path.join(self._output_path, "profiler")
|
||||||
if not os.path.exists(self._output_path):
|
if not os.path.exists(self._output_path):
|
||||||
os.makedirs(self._output_path, exist_ok=True)
|
os.makedirs(self._output_path, exist_ok=True)
|
||||||
|
os.chmod(self._output_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
else:
|
else:
|
||||||
logger.warning("The target dir already exists. "
|
logger.warning("The target dir already exists. "
|
||||||
"There may be some old profiling data, and they will be rewrote in the end.")
|
"There may be some old profiling data, and they will be rewrote in the end.")
|
||||||
|
|
Loading…
Reference in New Issue