Skip to content

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

feat: enhance memory management for GCU device support in clean_memory function

myhloli21c9267a9317
diff --git a/mineru/backend/vlm/utils.py b/mineru/backend/vlm/utils.py
index c64defa7..1be77c0d 100644
--- a/mineru/backend/vlm/utils.py
+++ b/mineru/backend/vlm/utils.py
@@ -18,6 +18,8 @@ def enable_custom_logits_processors() -> bool:
compute_capability = f"{major}.{minor}"
elif hasattr(torch, 'npu') and torch.npu.is_available():
compute_capability = "8.0"
+ elif hasattr(torch, 'gcu') and torch.gcu.is_available():
+ compute_capability = "8.0"
else:
logger.info("CUDA not available, disabling custom_logits_processors")
return False
diff --git a/mineru/utils/model_utils.py b/mineru/utils/model_utils.py
index 609b66be..63c67d97 100644
--- a/mineru/utils/model_utils.py
+++ b/mineru/utils/model_utils.py
@@ -414,7 +414,7 @@ def get_res_list_from_layout_res(layout_res, iou_threshold=0.7, overlap_threshol
def clean_memory(device='cuda'):
- if device == 'cuda':
+ if str(device).startswith("cuda"):
if torch.cuda.is_available():
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
@@ -423,6 +423,9 @@ def clean_memory(device='cuda'):
torch_npu.npu.empty_cache()
elif str(device).startswith("mps"):
torch.mps.empty_cache()
+ elif str(device).startswith("gcu"):
+ if torch.gcu.is_available():
+ torch.gcu.empty_cache()
gc.collect()