Memory leaks when doing CPU inference with MKLDNN
Created by: cryoco
System information Paddle version: 1.8.2 Paddle With CUDA: False OS: Ubuntu 16.04 CPU: 16 Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz Python version: 3.5.2 CUDA version: 9.0.176 cuDNN version: None.None.None Nvidia driver version: None API information: inference configuration
config.disable_gpu()
config.enable_mkldnn()
config.set_cpu_math_library_num_threads(4)
To Reproduce
- download models and data
- ocr detection model
- ocr recognition model
-
test data
The test data pictures are binary files saved with
np.save
, and can be loaded withnp.load
.
- perform inference with mkldnn code to reproduce: test_ocr_mkldnn_mem.txt(rename to test_ocr_mkldnn_mem.py)
- detection
python3 test_ocr_mkldnn_mem.py --model_file=./ch_det_mv3_db/model --params_file=./ch_det_mv3_db/params --mode=det --mkldnn
- recognition
python3 test_ocr_mkldnn_mem.py --model_file=./ch_rec_mv3_crnn/model --params_file=./ch_rec_mv3_crnn/params --mode=rec --mkldnn
Memory usage increasing can be witnessed with top
command.
- perform inference without mkldnn
- detection
python3 test_ocr_mkldnn_mem.py --model_file=./ch_det_mv3_db/model --params_file=./ch_det_mv3_db/params --mode=det
- recognition
python3 test_ocr_mkldnn_mem.py --model_file=./ch_rec_mv3_crnn/model --params_file=./ch_rec_mv3_crnn/params --mode=rec
Memory usage will maintain stable.
The input shapes we use in OCR are dynamic, which might be relevant to this issue.