未验证 提交 0cbdcdda 编写于 作者: R ronnywang 提交者: GitHub

call InitDevices only once (#47678)

上级 b4a3cca1
......@@ -164,7 +164,10 @@ void LoadCustomDevice(const std::string &library_dir) {
}
#endif
static std::once_flag init_devices_flag;
void InitDevices() {
std::call_once(init_devices_flag, []() {
// set name at the entry point of Paddle
platform::SetCurrentThreadName("MainThread");
// CUPTI attribute should be set before any CUDA context is created (see CUPTI
......@@ -197,8 +200,8 @@ void InitDevices() {
// use user specified XPUs in single-node multi-process mode.
devices = platform::GetSelectedNPUDevices();
} catch (const std::exception &exp) {
LOG(WARNING)
<< "Compiled with PADDLE_WITH_ASCEND_CL, but no NPU found in runtime.";
LOG(WARNING) << "Compiled with PADDLE_WITH_ASCEND_CL, but no NPU found "
"in runtime.";
}
#endif
#ifdef PADDLE_WITH_IPU
......@@ -219,6 +222,7 @@ void InitDevices() {
}
#endif
InitDevices(devices);
});
}
void InitDevices(const std::vector<int> devices) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册