Skip to content

Commit 0f2e7c0

Browse files
committed
mem: reduce PaddleOCR rec_batch_num from 6 to 1
Paddle's native inference engine allocates 500 MiB memory arena chunks during text recognition, proportional to batch size. With the default rec_batch_num=6, four 500 MiB chunks are allocated simultaneously. Setting rec_batch_num=1 reduces this to a single chunk, cutting peak memory on the PaddleOCR code path by ~1,265 MiB (-42.6%). Latency benchmark (55 text regions, CPU, 5 runs): - rec_batch_num=6: 39.1s +/- 3.5s - rec_batch_num=1: 37.0s +/- 2.0s No throughput regression — on CPU, batch processing is sequential.
1 parent 7c5855b commit 0f2e7c0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

unstructured/partition/utils/ocr_models/paddle_ocr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def load_agent(self, language: str):
4848
lang=language,
4949
enable_mkldnn=True,
5050
show_log=False,
51+
rec_batch_num=1,
5152
)
5253
except AttributeError:
5354
paddle_ocr = PaddleOCR(
@@ -56,6 +57,7 @@ def load_agent(self, language: str):
5657
lang=language,
5758
enable_mkldnn=False,
5859
show_log=False,
60+
rec_batch_num=1,
5961
)
6062
return paddle_ocr
6163

0 commit comments

Comments
 (0)