fix bug of Ascend context

pull/10150/head
caifubi 4 years ago
parent 4ce11a930b
commit 0e266beb6f

@ -335,16 +335,6 @@ bool AscendKernelRuntime::Load(session::KernelGraph *graph, bool is_task_sink) {
return true; return true;
} }
// Bind hccl context to current thread
if (graph->is_dynamic_shape()) {
if (rt_context_hccl_ != nullptr) {
auto ret = rtCtxSetCurrent(rt_context_hccl_);
if (ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "Call rtCtxSetCurrent failed, ret[" << ret << "]";
}
}
}
// Do HcomExecutorInitialize // Do HcomExecutorInitialize
if (graph->is_dynamic_shape() && !HcclExecutorManager::GetInstance().Initialize()) { if (graph->is_dynamic_shape() && !HcclExecutorManager::GetInstance().Initialize()) {
MS_LOG(ERROR) << "Init Hccl Executor Failed"; MS_LOG(ERROR) << "Init Hccl Executor Failed";
@ -712,17 +702,17 @@ bool AscendKernelRuntime::InitDevice() {
} }
} }
ret = rtCtxGetCurrent(&rt_context_hccl_); // Context will be created by rtSetDevice
if (ret != RT_ERROR_NONE || rt_context_hccl_ == nullptr) { ret = rtCtxGetCurrent(&rt_context_);
if (ret != RT_ERROR_NONE || rt_context_ == nullptr) {
MS_LOG(ERROR) << "Call rtCtxGetCurrent failed, ret[" << ret << "]"; MS_LOG(ERROR) << "Call rtCtxGetCurrent failed, ret[" << ret << "]";
return false; return false;
} }
CreateContext();
ret = rtStreamCreate(&stream_, 0); ret = rtStreamCreate(&stream_, 0);
if (ret != RT_ERROR_NONE) { if (ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "Call rtStreamCreate, ret[" << ret << "]"; MS_LOG(EXCEPTION) << "Call rtStreamCreate, ret[" << ret << "]";
} }
return true; return true;
} }
@ -736,21 +726,12 @@ bool AscendKernelRuntime::ResetDevice(uint32_t device_id) {
stream_ = nullptr; stream_ = nullptr;
} }
if (rt_context_ != nullptr) {
auto ret = rtCtxDestroy(rt_context_);
if (ret != RT_ERROR_NONE) {
MS_EXCEPTION(DeviceProcessError) << "Call rtCtxDestroy, ret[" << ret << "]";
}
rt_context_ = nullptr;
}
auto ret = rtDeviceReset(device_id); auto ret = rtDeviceReset(device_id);
if (ret != RT_ERROR_NONE) { if (ret != RT_ERROR_NONE) {
MS_EXCEPTION(DeviceProcessError) << "Call rtDeviceReset, ret[" << ret << "]"; MS_EXCEPTION(DeviceProcessError) << "Call rtDeviceReset, ret[" << ret << "]";
} }
// set to nullptr as its not created, only bounded to existing context // set to nullptr as its not created, only bounded to existing context
rt_context_hccl_ = nullptr; rt_context_ = nullptr;
return true; return true;
} }

@ -85,7 +85,6 @@ class AscendKernelRuntime : public KernelRuntime {
void ReportProfilingData(); void ReportProfilingData();
rtContext_t rt_context_{nullptr}; rtContext_t rt_context_{nullptr};
rtContext_t rt_context_hccl_{nullptr};
bool initialized_{false}; bool initialized_{false};
unordered_map<GraphId, vector<std::shared_ptr<TaskInfo>>> task_map_; unordered_map<GraphId, vector<std::shared_ptr<TaskInfo>>> task_map_;
unordered_map<GraphId, std::shared_ptr<ge::model_runner::DavinciModel>> graph_model_map_; unordered_map<GraphId, std::shared_ptr<ge::model_runner::DavinciModel>> graph_model_map_;

Loading…
Cancel
Save