From 5c8455d6ea87712cf711863c3a466059bea779e8 Mon Sep 17 00:00:00 2001 From: QingshuChen Date: Wed, 3 Feb 2021 15:52:59 +0800 Subject: [PATCH] try again if kunlun memory malloc failed (#30855) * try again if kunlun memory malloc failed * minor --- paddle/fluid/memory/allocation/naive_best_fit_allocator.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc index dbea74e7e0f..6306ad5ffc8 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc @@ -135,6 +135,11 @@ void *Alloc(const platform::XPUPlace &place, size_t size) { "Baidu Kunlun Card is properly installed.", ret)); ret = xpu_malloc(reinterpret_cast(&p), size); + if (ret != XPU_SUCCESS) { + std::cout << "xpu memory malloc(" << size << ") failed, try again\n"; + xpu_wait(); + ret = xpu_malloc(reinterpret_cast(&p), size); + } PADDLE_ENFORCE_EQ( ret, XPU_SUCCESS, platform::errors::External( -- GitLab