独立指南——与 IBM 及 Docling 项目无隶属关系。 所有命令均在 Docling 2.148.0 上验证。
  1. 首页
  2. 安装
  3. macOS
安装 · macOS

在 Mac 上安装 Docling——让 Apple Silicon 承担重活

在 Apple Silicon 上,普通的 pip install docling 就已通过 PyTorch 的 MPS 后端包含 GPU 加速;两个 Mac 专属组件——Apple Vision OCR 和 MLX 模型——能让它更快。先了解两个版本细节。

已在 Docling 上验证 2.148.0更新于 2026年11月6日5 分钟阅读
要点速览
  • 在 Python 3.10–3.14 的虚拟环境中 pip install docling;会自动使用 MPS(--device auto)。
  • 在 Apple Silicon 上,2.11 之后的 PyTorch 安装包需要 macOS 14 或更高;macOS 11–13 上 pip 会安装 torch 2.11.0。
  • Intel Mac 会装到 torch 2.2.2——最后一个 Intel macOS 版本。Docling 仍能安装,但 PyTorch 更旧、速度更慢。
  • 加装 docling[ocrmac] 获得 Apple Vision OCR,加装 docling[vlm] 获得 MLX 加速的 Granite-Docling。

安装#

bash
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 --version

macOS 上不需要单独安装 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–132.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 模型。
bash
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 安装可选工具#

bash
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 上进行。

资料来源