From f65b5abce2693564aa93376dd84889a72b3156c9 Mon Sep 17 00:00:00 2001 From: xuanyue Date: Thu, 21 Aug 2025 19:44:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/extendrt/kernel/ascend/model/model_infer.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mindspore-lite/src/extendrt/kernel/ascend/model/model_infer.cc b/mindspore-lite/src/extendrt/kernel/ascend/model/model_infer.cc index 713d7607..76837b26 100644 --- a/mindspore-lite/src/extendrt/kernel/ascend/model/model_infer.cc +++ b/mindspore-lite/src/extendrt/kernel/ascend/model/model_infer.cc @@ -79,7 +79,7 @@ bool ModelInfer::Init() { } } - ret = CALL_ASCEND_API(aclrtGetCurrentContext, &context_); + ret = CALL_ASCEND_API(aclrtCreateContext, &context_, device_id); if (ret != ACL_SUCCESS) { MS_LOG(ERROR) << "Acl create context failed."; return false; @@ -133,8 +133,11 @@ bool ModelInfer::Finalize(bool process_ends) { stream_ = nullptr; } if (context_ != nullptr) { + rt_ret = CALL_ASCEND_API(aclrtDestroyContext, context_); + if (rt_ret != ACL_SUCCESS) { + MS_LOG(ERROR) << "Destroy context failed"; + } context_ = nullptr; - MS_LOG(INFO) << "use default context, not destroy context"; } MS_LOG(INFO) << "End to destroy context."; if (process_ends || AclEnvGuard::GetModelNum() == 0) { -- Gitee