Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve mklml memory leak on windows #24015

Merged
merged 3 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmake/external/mklml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ SET(MKLML_INC_DIR ${MKLML_ROOT}/include)
SET(MKLML_LIB_DIR ${MKLML_ROOT}/lib)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_ROOT}/lib")

SET(TIME_VERSION "2019.0.1.20181227")
IF(WIN32)
SET(MKLML_VER "mklml_win_${TIME_VERSION}" CACHE STRING "" FORCE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

报错在这个地方 http://10.87.145.41:8111/viewLog.html?buildId=332739&buildTypeId=PaddleWindows_PrWindowsCi&tab=buildLog&branch_PaddleWindows=pull%2F24015&_focus=993
新的mklml比原来版本少了个msvcr120.dll,导致在这个地方
https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/pybind/CMakeLists.txt#L69-L74 拷贝出错了,需要看以下是要改mklml.cmake还是op_function_cmd这里

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新的mklml比原来版本少了个msvcr120.dll

@yinghu5 能帮忙看下这个msvcr120.dll是不是不需要了?

SET(MKLML_VER "mklml_win_2019.0.5.20190502" CACHE STRING "" FORCE)
SET(MKLML_URL "https://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.zip" CACHE STRING "" FORCE)
SET(MKLML_LIB ${MKLML_LIB_DIR}/mklml.lib)
SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.lib)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以不需要,编译没问题。把依赖MKLML_SHARED_LIB_DEPS的地方去掉,有4个地方。另外demo_ci/CMakeLists.txt中有一个msvcr120.dll也需要去掉,共5个位置。

Expand Down
8 changes: 2 additions & 6 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,11 @@ bool AnalysisPredictor::Run(const std::vector<PaddleTensor> &inputs,
#ifdef PADDLE_WITH_MKLDNN
if (config_.use_mkldnn_) MkldnnPostReset();
#endif
#if defined(PADDLE_WITH_MKLML) && defined(_LINUX)
#if defined(PADDLE_WITH_MKLML)
// 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;
}
Expand Down Expand Up @@ -660,13 +658,11 @@ 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)
#if defined(PADDLE_WITH_MKLML)
// 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;
}
Expand Down