forked from mindspore-Ecosystem/mindspore
profiler init add aclrtSetDevice
This commit is contained in:
parent
4263ada607
commit
313095aac9
|
@ -28,6 +28,7 @@
|
|||
#include "plugin/device/ascend/hal/device/profiling/profiling_reporter.h"
|
||||
#include "kernel/kernel.h"
|
||||
#include "backend/common/session/kernel_graph.h"
|
||||
#include "acl/acl_rt.h"
|
||||
|
||||
using mindspore::device::ascend::ProfilingManager;
|
||||
using mindspore::device::ascend::ProfilingReporter;
|
||||
|
@ -69,6 +70,11 @@ void AscendProfiler::InitProfiling(const std::string &profiling_path, uint32_t d
|
|||
profile_data_path_ = profiling_path;
|
||||
device_id_ = device_id;
|
||||
|
||||
aclError ret = aclrtSetDevice(static_cast<int32_t>(device_id));
|
||||
if (ret != ACL_ERROR_NONE) {
|
||||
MS_LOG(EXCEPTION) << "Device " << device_id << " call aclrtSetDevice failed, ret[" << static_cast<int>(ret) << "]";
|
||||
}
|
||||
|
||||
// Init ErrorManager instance in order to get error msg reported by Ascend.
|
||||
if (ErrorManager::GetInstance().Init() != 0) {
|
||||
MS_LOG(WARNING) << "[Internal Error] Failed to init ErrorManager class.";
|
||||
|
|
|
@ -175,8 +175,10 @@ class DataPreProcessParser:
|
|||
ai_cpu = AiCpuStruct(*ai_cpu_data)
|
||||
if ai_cpu.task_id < self._task_id_threshold:
|
||||
node_type_name = f'{ai_cpu.stream_id}_{ai_cpu.task_id}'
|
||||
if self._op_task_dict:
|
||||
if self._op_task_dict and node_type_name in self._op_task_dict:
|
||||
node_type_name = self._op_task_dict[node_type_name].split('/')[-1]
|
||||
else:
|
||||
logger.warning("[profiler] the op name of %s cannot be found.", node_type_name)
|
||||
exe_time = (float(ai_cpu.run_end) - float(ai_cpu.run_start)) / self._ms_unit
|
||||
total_time = ai_cpu.total_time / self._ms_unit
|
||||
result_list.append([serial_number, node_type_name, total_time, ai_cpu.dispatch_time / self._ms_unit,
|
||||
|
|
|
@ -177,10 +177,10 @@ class TestProfiler:
|
|||
if ds_train.get_dataset_size() == 0:
|
||||
raise ValueError("Please check dataset size > 0 and batch_size <= dataset size")
|
||||
|
||||
lenet = LeNet5()
|
||||
profiler = Profiler(profile_memory=profile_memory, output_path='data')
|
||||
profiler_name = os.listdir(os.path.join(os.getcwd(), 'data'))[0]
|
||||
self.profiler_path = os.path.join(os.getcwd(), f'data/{profiler_name}/')
|
||||
lenet = LeNet5()
|
||||
loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction="mean")
|
||||
optim = Momentum(lenet.trainable_params(), learning_rate=0.1, momentum=0.9)
|
||||
model = Model(lenet, loss_fn=loss, optimizer=optim, metrics={'acc': Accuracy()})
|
||||
|
|
|
@ -62,4 +62,17 @@ ACL_FUNC_VISIBILITY aclError aclrtMemcpy(void *dst, size_t destMax, const void *
|
|||
ACL_FUNC_VISIBILITY aclError aclrtMemcpyAsync(void *dst, size_t destMax, const void *src, size_t count,
|
||||
aclrtMemcpyKind kind, aclrtStream stream) {
|
||||
return ACL_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup AscendCL
|
||||
* @brief Specify the device used for computing in the current process, and implicitly create a default context
|
||||
*
|
||||
* @param deviceId [IN] the device id of the resource used by this process
|
||||
*
|
||||
* @retval ACL_SUCCESS The function is successfully executed.
|
||||
* @retval OtherValues Failure
|
||||
*/
|
||||
ACL_FUNC_VISIBILITY aclError aclrtSetDevice(int32_t deviceId) {
|
||||
return ACL_ERROR_NONE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue