|
|
|
@ -37,6 +37,9 @@
|
|
|
|
|
#include "paddle/fluid/inference/utils/singleton.h"
|
|
|
|
|
#include "paddle/fluid/memory/memcpy.h"
|
|
|
|
|
#include "paddle/fluid/platform/cpu_helper.h"
|
|
|
|
|
#ifdef PADDLE_WITH_MKLML
|
|
|
|
|
#include "paddle/fluid/platform/dynload/mklml.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include "paddle/fluid/platform/gpu_info.h"
|
|
|
|
|
#include "paddle/fluid/platform/place.h"
|
|
|
|
|
#include "paddle/fluid/platform/profiler.h"
|
|
|
|
@ -308,6 +311,14 @@ bool AnalysisPredictor::Run(const std::vector<PaddleTensor> &inputs,
|
|
|
|
|
paddle::platform::SetNumThreads(1);
|
|
|
|
|
#ifdef PADDLE_WITH_MKLDNN
|
|
|
|
|
if (config_.use_mkldnn_) MkldnnPostReset();
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(PADDLE_WITH_MKLML) && defined(_LINUX)
|
|
|
|
|
// Frees unused memory allocated by the Intel® MKL Memory Allocator to
|
|
|
|
|
// avoid memory leak. See:
|
|
|
|
|
// https://software.intel.com/en-us/mkl-developer-reference-c-mkl-free-buffers
|
|
|
|
|
platform::dynload::MKL_Free_Buffers();
|
|
|
|
|
// We don't support windows since MKL_Free_Buffers is not in
|
|
|
|
|
// mklml_win_2019.0.1.20181227.zip. We will upgrade mklml_win version later.
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -648,6 +659,14 @@ bool AnalysisPredictor::ZeroCopyRun() {
|
|
|
|
|
// recover the cpu_math_library_num_threads to 1, in order to avoid thread
|
|
|
|
|
// conflict when integrating it into deployment service.
|
|
|
|
|
paddle::platform::SetNumThreads(1);
|
|
|
|
|
#if defined(PADDLE_WITH_MKLML) && defined(_LINUX)
|
|
|
|
|
// Frees unused memory allocated by the Intel® MKL Memory Allocator to
|
|
|
|
|
// avoid memory leak. See:
|
|
|
|
|
// https://software.intel.com/en-us/mkl-developer-reference-c-mkl-free-buffers
|
|
|
|
|
platform::dynload::MKL_Free_Buffers();
|
|
|
|
|
// We don't support windows since MKL_Free_Buffers is not in
|
|
|
|
|
// mklml_win_2019.0.1.20181227.zip. We will upgrade mklml_win version later.
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|