Skip to content

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

feat: add GCU device support for bf16 and memory calculations

myhloli7620bd4ccc66
diff --git a/mineru/utils/block_sort.py b/mineru/utils/block_sort.py
index 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 = True
elif device_name.startswith("mps"):
bf_16_support = True
+ elif device_name.startswith("gcu"):
+ if torch.gcu.is_bf16_supported():
+ bf_16_support = True
if model_name == 'layoutreader':
# 检测modelscope的缓存目录是否存在
diff --git a/mineru/utils/config_reader.py b/mineru/utils/config_reader.py
index 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:
+ pass
return "cpu"
diff --git a/mineru/utils/model_utils.py b/mineru/utils/model_utils.py
index 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)) # 转为 GB
return total_memory