Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
feat: add GCU device support for bf16 and memory calculations
myhloli7620bd4ccc66
diff --git a/mineru/utils/block_sort.py b/mineru/utils/block_sort.pyindex 23fafd22..b419f265 100644--- a/mineru/utils/block_sort.py+++ b/mineru/utils/block_sort.py@@ -186,6 +186,9 @@ def model_init(model_name: str):bf_16_support = Trueelif device_name.startswith("mps"):bf_16_support = True+ elif device_name.startswith("gcu"):+ if torch.gcu.is_bf16_supported():+ bf_16_support = Trueif model_name == 'layoutreader':# 检测modelscope的缓存目录是否存在diff --git a/mineru/utils/config_reader.py b/mineru/utils/config_reader.pyindex f6d013ea..7f73dc1a 100644--- a/mineru/utils/config_reader.py+++ b/mineru/utils/config_reader.py@@ -86,7 +86,11 @@ def get_device():if torch_npu.npu.is_available():return "npu"except Exception as e:- pass+ try:+ if torch.gcu.is_available():+ return "gcu"+ except Exception as e:+ passreturn "cpu"diff --git a/mineru/utils/model_utils.py b/mineru/utils/model_utils.pyindex 5ce4be12..609b66be 100644--- a/mineru/utils/model_utils.py+++ b/mineru/utils/model_utils.py@@ -458,5 +458,8 @@ def get_vram(device) -> int:elif str(device).startswith("npu"):if torch_npu.npu.is_available():total_memory = round(torch_npu.npu.get_device_properties(device).total_memory / (1024 ** 3)) # 转为 GB+ elif str(device).startswith("gcu"):+ if torch.gcu.is_available():+ total_memory = round(torch.gcu.get_device_properties(device).total_memory / (1024 ** 3)) # 转为 GBreturn total_memory