From 060d640c2b67c80a4b821d33f99ec79c22a3736a Mon Sep 17 00:00:00 2001 From: yu-liang-bin Date: Sat, 13 Sep 2025 15:17:09 +0800 Subject: [PATCH] fix cann --- .../prof_view/cann_parse/_cann_export.py | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/torch_npu/profiler/analysis/prof_view/cann_parse/_cann_export.py b/torch_npu/profiler/analysis/prof_view/cann_parse/_cann_export.py index 5b37f8c89f..f006330e87 100644 --- a/torch_npu/profiler/analysis/prof_view/cann_parse/_cann_export.py +++ b/torch_npu/profiler/analysis/prof_view/cann_parse/_cann_export.py @@ -97,26 +97,32 @@ class CANNExportParser(BaseParser): return False def _check_msprof_path(self): + error_message = "" if not self.msprof_path: - raise RuntimeError("Export CANN Profiling data failed! 'msprof' command not found!" - + prof_error(ErrCode.NOT_FOUND)) + error_message += "Export CANN Profiling data failed! 'msprof' command not found!" \ + + prof_error(ErrCode.NOT_FOUND) + "\n" if not ProfilerPathManager.check_path_permission(self.msprof_path): - raise PermissionError(f"The '{self.msprof_path}' path and current owner have inconsistent permissions." - f"please execute 'chown -R {pwd.getpwuid(os.getuid()).pw_name} " - f"{os.path.normpath(os.path.join(self.msprof_path, '../../..'))}'" - + prof_error(ErrCode.PERMISSION)) + error_message += f"The '{self.msprof_path}' path and current owner have inconsistent permissions." \ + f"please execute 'chown -R {pwd.getpwuid(os.getuid()).pw_name} " \ + f"{os.path.normpath(os.path.join(self.msprof_path, '../../..'))}'" \ + + prof_error(ErrCode.PERMISSION) + "\n" msprof_script_path = self._get_msprof_script_path(self._MSPROF_PY_PATH) if not msprof_script_path: - raise FileNotFoundError( - f"Failed to find msprof.py path in {self.msprof_path}. Please check the CANN environment." - ) + error_message += f"Failed to find msprof.py path in {self.msprof_path}. Please check the CANN environment." \ + + prof_error(ErrCode.NOT_FOUND) + "\n" # The path "os.path.join(msprof_script_path, '../../../../../../..')" represents the layer of "ascend-toolkit", # such as "xxx/ascend-toolkit" if not ProfilerPathManager.check_path_permission(msprof_script_path): - raise PermissionError(f"The '{msprof_script_path}' path and current owner have inconsistent permissions." - f"please execute 'chown -R {pwd.getpwuid(os.getuid()).pw_name} " - f"{os.path.normpath(os.path.join(msprof_script_path, '../../../../../../..'))}'" - + prof_error(ErrCode.PERMISSION)) + error_message += f"The '{msprof_script_path}' path and current owner have inconsistent permissions." \ + f"please execute 'chown -R {pwd.getpwuid(os.getuid()).pw_name} " \ + f"{os.path.normpath(os.path.join(msprof_script_path, '../../../../../../..'))}'" \ + + prof_error(ErrCode.PERMISSION) + "\n" + if ProfilerPathManager.path_is_other_writable(msprof_script_path): + error_message += f"Path '{msprof_script_path}' permission allow others users to write. " \ + f"Please execute 'chmod -R 755 '{msprof_script_path}' '" \ + + prof_error(ErrCode.PERMISSION) + if error_message: + raise RuntimeError(error_message) def _get_msprof_script_path(self, script_path: str) -> str: msprof_path = os.path.realpath(self.msprof_path.strip()) -- Gitee