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::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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue