安装#
brew install python@3.12 # 或使用 python.org 安装程序
python3.12 -m venv ~/docling-env && source ~/docling-env/bin/activate
pip install -U pip
pip install "docling[ocrmac]" # 包含 Apple Vision OCR
docling --versionmacOS 上不需要单独安装 PyTorch:PyPI 的 macOS 安装包不会拉取 NVIDIA 库,并且自带 MPS 支持。
你会得到哪个 PyTorch#
| Mac | 为 Docling 2.148.0 解析出的 PyTorch | 原因 |
|---|---|---|
| Apple Silicon,macOS 14+ | 2.15.0(最新) | 从 2.12.0 起安装包标签为 macosx_14_0_arm64 |
| Apple Silicon,macOS 11–13 | 2.11.0 | 最后一个带 macosx_11_0_arm64 安装包的版本 |
| Intel(x86_64) | 2.2.2 | 最后一个提供 Intel macOS 安装包的 PyTorch 版本 |
以上结果用 uv 解析器针对 Python 3.12 检查,并与 PyPI 上的安装包标签核对。Docling 要求 torch>=2.2.2,所以 Intel Mac 仍然可用。
Apple Silicon 加速#
- 版面、表格、OCR 模型:自动在 MPS 上运行。可用
--device mps强制。 - Apple Vision OCR:
--ocr-engine ocrmac;语言使用 Apple 的代码,如en-US、zh-Hans、ja-JP,或iso:标签。--ocr-option recognition=fast以精度换速度。 - VLM 的 MLX 加速:
pip install "docling[vlm]"会在 Apple Silicon 上加入mlx-vlm;带 MLX 版本的预设(Granite-Docling、SmolDocling、Qwen、Pixtral、Gemma……)会自动使用它。 - 音频的 MLX 加速:
docling[asr]会加入mlx-whisper;用--asr-model选择whisper_*_mlx模型。
docling convert scan.pdf --ocr-engine ocrmac --ocr-lang zh-Hans
docling convert report.pdf --pipeline vlm --vlm-model granite_docling
docling convert meeting.m4a --pipeline asr --asr-model whisper_turbo_mlx通过 Homebrew 安装可选工具#
brew install tesseract tesseract-lang # Tesseract 引擎 + 全部语言
brew install --cask libreoffice # .doc、.ppt、.xls、.rtf
brew install ffmpeg # 音频和视频常见问题
Docling 会使用 Apple Silicon 的 GPU 吗?
会。PyTorch 的 MPS 后端包含在标准 macOS 安装包中,Docling 默认的 --device auto 在没有 CUDA 时会选择 MPS。也可以用 --device mps 强制使用。
Mac 上 Docling 最好的 OCR 引擎是哪个?
ocrmac,它使用 Apple 内置的 Vision 框架:无需下载模型,多语言支持良好,中文用 zh-Hans。安装 docling[ocrmac] 并传入 --ocr-engine ocrmac。在 macOS 上,自动引擎在已安装 ocrmac 时也会优先尝试它。
能在 Intel Mac 上运行 Docling 吗?
可以。Docling 2.148.0 能安装,但 PyTorch 在 2.2.2 之后不再发布 Intel macOS 安装包,所以 pip 会安装该版本。所有计算都在 CPU 上进行。
资料来源
- PyPI 上的 torch:macOS 安装包标签(2.11.0:macosx_11_0;2.12.0+:macosx_14_0)
- PyPI 上的 ocrmac
- ibm-granite/granite-docling-258M-mlx
内容准确吗?当 Docling 新版本改变行为时,我们会重新验证页面。如果某条命令对你无效,请把 Docling 版本号和报错发到 hello@docling.org,更正通常一天内上线。