!2752 fix mix target device id

Merge pull request !2752 from kisnwang/fix-mix-session-device-id
This commit is contained in:
mindspore-ci-bot 2020-06-30 17:18:30 +08:00 committed by Gitee
commit d454daec1b
1 changed files with 4 additions and 1 deletions

View File

@ -353,7 +353,10 @@ void MsBackend::CreateOtherSession(const std::string &target) {
if (other_sess_ == nullptr) {
MS_LOG(EXCEPTION) << "Session create failed!, please make sure target device:" << target << " is available.";
}
other_sess_->Init(0);
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
uint32_t device_id = context_ptr->device_id();
other_sess_->Init(device_id);
other_sess_->RegisterSummaryCallBackFunc(callbacks::SummarySaveCallback);
other_device_ = target;
}