Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

perf(inference): adjust batch ratio thresholds for GPU memory sizes

myhloli74e954daceae
diff --git a/magic_pdf/model/doc_analyze_by_custom_model.py b/magic_pdf/model/doc_analyze_by_custom_model.py
index 1dac5c65..ef6a622e 100644
--- a/magic_pdf/model/doc_analyze_by_custom_model.py
+++ b/magic_pdf/model/doc_analyze_by_custom_model.py
@@ -257,13 +257,15 @@ def may_batch_image_analyze(
if str(device).startswith('npu') or str(device).startswith('cuda'):
gpu_memory = int(os.getenv('VIRTUAL_VRAM_SIZE', round(get_vram(device))))
if gpu_memory is not None:
- if gpu_memory >= 20:
+ if gpu_memory >= 24:
+ batch_ratio = 32
+ elif gpu_memory >= 16:
batch_ratio = 16
- elif gpu_memory >= 15:
+ elif gpu_memory >= 12:
batch_ratio = 8
- elif gpu_memory >= 10:
+ elif gpu_memory >= 8:
batch_ratio = 4
- elif gpu_memory >= 7:
+ elif gpu_memory >= 6:
batch_ratio = 2
else:
batch_ratio = 1