Remove the constraint that gpu profiler initialized in specific position

This commit is contained in:
gzhcv 2021-03-30 20:34:54 +08:00
parent 5573f1609a
commit f8918115bb
3 changed files with 8 additions and 11 deletions

View File

@ -22,17 +22,17 @@
#include "utils/log_adapter.h"
#include "utils/ms_utils.h"
#include "utils/utils.h"
#include "utils/ms_context.h"
namespace mindspore {
namespace kernel {
GetNextProfiling::GetNextProfiling(const std::string &path) : profiling_path_(path) {}
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() {

View File

@ -986,12 +986,11 @@ class CpuTimelineGenerator(GpuTimelineGenerator):
"""Get timeline data from file."""
timeline_list = self.load_cpu_op_data()
factor_ns_to_ms = 1e6
factor_us_to_ms = 1e3
start_time = 2
duration = 3
for idx, time_item in enumerate(timeline_list):
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
return timeline_list

View File

@ -278,11 +278,9 @@ class Profiler:
def _gpu_analyse(self):
"""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())
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()
timeline_generator = self._generate_timeline()