| @@ -22,17 +22,17 @@ | |||||
| #include "utils/log_adapter.h" | #include "utils/log_adapter.h" | ||||
| #include "utils/ms_utils.h" | #include "utils/ms_utils.h" | ||||
| #include "utils/utils.h" | #include "utils/utils.h" | ||||
| #include "utils/ms_context.h" | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace kernel { | namespace kernel { | ||||
| GetNextProfiling::GetNextProfiling(const std::string &path) : profiling_path_(path) {} | GetNextProfiling::GetNextProfiling(const std::string &path) : profiling_path_(path) {} | ||||
| void GetNextProfiling::GetDeviceId() { | void GetNextProfiling::GetDeviceId() { | ||||
| // If DEVICE_ID is not set,defult value is 0 | |||||
| device_id_ = common::GetEnv("DEVICE_ID"); | |||||
| if (device_id_.empty()) { | |||||
| device_id_ = "0"; | |||||
| } | |||||
| auto context_ptr = MsContext::GetInstance(); | |||||
| MS_EXCEPTION_IF_NULL(context_ptr); | |||||
| auto device_id = context_ptr->get_param<uint32_t>(MS_CTX_DEVICE_ID); | |||||
| device_id_ = std::to_string(device_id); | |||||
| } | } | ||||
| void GetNextProfiling::Init() { | void GetNextProfiling::Init() { | ||||
| @@ -986,12 +986,11 @@ class CpuTimelineGenerator(GpuTimelineGenerator): | |||||
| """Get timeline data from file.""" | """Get timeline data from file.""" | ||||
| timeline_list = self.load_cpu_op_data() | timeline_list = self.load_cpu_op_data() | ||||
| factor_ns_to_ms = 1e6 | factor_ns_to_ms = 1e6 | ||||
| factor_us_to_ms = 1e3 | |||||
| start_time = 2 | start_time = 2 | ||||
| duration = 3 | duration = 3 | ||||
| for idx, time_item in enumerate(timeline_list): | for idx, time_item in enumerate(timeline_list): | ||||
| time_item[start_time] = float(time_item[start_time]) / factor_ns_to_ms | time_item[start_time] = float(time_item[start_time]) / factor_ns_to_ms | ||||
| time_item[duration] = float(time_item[duration]) / factor_us_to_ms | |||||
| time_item[duration] = float(time_item[duration]) | |||||
| timeline_list[idx] = time_item | timeline_list[idx] = time_item | ||||
| return timeline_list | return timeline_list | ||||
| @@ -278,11 +278,9 @@ class Profiler: | |||||
| def _gpu_analyse(self): | def _gpu_analyse(self): | ||||
| """Collect and analyse gpu performance data""" | """Collect and analyse gpu performance data""" | ||||
| if GlobalComm.WORLD_COMM_GROUP == "nccl_world_group" and self._dev_id != str(get_rank()): | |||||
| self._dev_id = context.get_context("device_id") | |||||
| if GlobalComm.WORLD_COMM_GROUP == "nccl_world_group": | |||||
| self._dev_id = str(get_rank()) | self._dev_id = str(get_rank()) | ||||
| logger.error('Please check the Profiler object initialized after mindspore.context.set_auto_parallel_' | |||||
| 'context() and mindspore.communication.management.init(). Profiler should be initialized' | |||||
| ' after these code.') | |||||
| self._gpu_profiler.stop() | self._gpu_profiler.stop() | ||||
| timeline_generator = self._generate_timeline() | timeline_generator = self._generate_timeline() | ||||