diff --git a/lite/api/cxx_api_impl.cc b/lite/api/cxx_api_impl.cc index 3b3337139b3c5e3d475503ac682194a0ed348e4f..a41c1d0a30508536a77d6013ae401a4beedbd9a5 100644 --- a/lite/api/cxx_api_impl.cc +++ b/lite/api/cxx_api_impl.cc @@ -58,6 +58,16 @@ void CxxPaddleApiImpl::Init(const lite_api::CxxConfig &config) { config.mlu_input_layout(), config.mlu_firstconv_param()); #endif // LITE_WITH_MLU + +#ifdef LITE_WITH_BM + Env::Init(); + int device_id = 0; + if (const char *c_id = getenv("BM_VISIBLE_DEVICES")) { + device_id = static_cast(*c_id) - 48; + } + TargetWrapper::SetDevice(device_id); +#endif // LITE_WITH_BM + auto use_layout_preprocess_pass = config.model_dir().find("OPENCL_PRE_PRECESS"); VLOG(1) << "use_layout_preprocess_pass:" << use_layout_preprocess_pass;