Skip to content

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

fix: simplify GPU memory batch ratio calculation and enhance logging message

myhloli9fc13e3d8844
diff --git a/mineru/backend/pipeline/pipeline_analyze.py b/mineru/backend/pipeline/pipeline_analyze.py
index d56dedab..f765c666 100644
--- a/mineru/backend/pipeline/pipeline_analyze.py
+++ b/mineru/backend/pipeline/pipeline_analyze.py
@@ -174,18 +174,20 @@ def batch_image_analyze(
) from e
gpu_memory = get_vram(device)
- if gpu_memory is not None:
- if gpu_memory >= 16:
- batch_ratio = 16
- elif gpu_memory >= 12:
- batch_ratio = 8
- elif gpu_memory >= 8:
- batch_ratio = 4
- elif gpu_memory >= 6:
- batch_ratio = 2
- else:
- batch_ratio = 1
- logger.info(f'gpu_memory: {gpu_memory} GB, batch_ratio: {batch_ratio}')
+ if gpu_memory >= 16:
+ batch_ratio = 16
+ elif gpu_memory >= 12:
+ batch_ratio = 8
+ elif gpu_memory >= 8:
+ batch_ratio = 4
+ elif gpu_memory >= 6:
+ batch_ratio = 2
+ else:
+ batch_ratio = 1
+ logger.info(
+ f'GPU Memory: {gpu_memory} GB, Batch Ratio: {batch_ratio}. '
+ f'You can set MINERU_VIRTUAL_VRAM_SIZE environment variable to adjust GPU memory allocation.'
+ )
# 检测torch的版本号
import torch