From 04d01a36f452f66aeeb29bacc716e9d120dced3e Mon Sep 17 00:00:00 2001 From: kswang Date: Tue, 30 Jun 2020 15:17:13 +0800 Subject: [PATCH] fix mix target device id --- mindspore/ccsrc/vm/backend.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/vm/backend.cc b/mindspore/ccsrc/vm/backend.cc index 1a27fcb63a..47bc69bbbb 100644 --- a/mindspore/ccsrc/vm/backend.cc +++ b/mindspore/ccsrc/vm/backend.cc @@ -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; }