From 5858441b3d95c15ba040c061ae968f1e19f879b7 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Tue, 15 Sep 2020 15:52:52 +0000 Subject: [PATCH] add notes --- deploy/cpp_infer/src/ocr_det.cpp | 1 + deploy/cpp_infer/src/ocr_rec.cpp | 1 + deploy/cpp_infer/tools/config.txt | 2 +- tools/infer/utility.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/deploy/cpp_infer/src/ocr_det.cpp b/deploy/cpp_infer/src/ocr_det.cpp index a935003b..bf94abce 100644 --- a/deploy/cpp_infer/src/ocr_det.cpp +++ b/deploy/cpp_infer/src/ocr_det.cpp @@ -26,6 +26,7 @@ void DBDetector::LoadModel(const std::string &model_dir) { config.DisableGpu(); if (this->use_mkldnn_) { config.EnableMKLDNN(); + // cache 10 different shapes for mkldnn to avoid memory leak config.SetMkldnnCacheCapacity(10); } config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_); diff --git a/deploy/cpp_infer/src/ocr_rec.cpp b/deploy/cpp_infer/src/ocr_rec.cpp index 9d71d8c4..b997d829 100644 --- a/deploy/cpp_infer/src/ocr_rec.cpp +++ b/deploy/cpp_infer/src/ocr_rec.cpp @@ -126,6 +126,7 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) { config.DisableGpu(); if (this->use_mkldnn_) { config.EnableMKLDNN(); + // cache 10 different shapes for mkldnn to avoid memory leak config.SetMkldnnCacheCapacity(10); } config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_); diff --git a/deploy/cpp_infer/tools/config.txt b/deploy/cpp_infer/tools/config.txt index 40beea3a..6c53f29e 100644 --- a/deploy/cpp_infer/tools/config.txt +++ b/deploy/cpp_infer/tools/config.txt @@ -3,7 +3,7 @@ use_gpu 0 gpu_id 0 gpu_mem 4000 cpu_math_library_num_threads 10 -use_mkldnn 0 +use_mkldnn 1 use_zero_copy_run 1 # det config diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 1d07f62f..3e1f07b8 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -101,6 +101,7 @@ def create_predictor(args, mode): config.disable_gpu() config.set_cpu_math_library_num_threads(6) if args.enable_mkldnn: + # cache 10 different shapes for mkldnn to avoid memory leak config.set_mkldnn_cache_capacity(10) config.enable_mkldnn() -- GitLab