docling-project / docling-project/docling
Docling is unusable on long PDFs with CUDA
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
I am running Docling on L4 GPU from modal labs. For whatever reason, it only uses 1.4GB of VRAM and is stuck at 3% GPU utilization regardless of the num_threads I use. In the logs I see this:
INFO:docling.document_converter:Going to convert document batch...
--
Apr 05 19:51:59.941 | INFO:docling.document_converter:Initializing pipeline for StandardPdfPipeline with options hash e273ea4f9afaa9373468db25fd55d8a1
Apr 05 19:51:59.956 | INFO:docling.models.factories.base_factory:Loading plugin 'docling_defaults'
Apr 05 19:51:59.961 | INFO:docling.models.factories:Registered ocr engines: ['easyocr', 'ocrmac', 'rapidocr', 'tesserocr', 'tesseract']
Apr 05 19:52:00.196 | INFO:docling.utils.accelerator_utils:Accelerator device: 'cuda:0'
Apr 05 19:52:01.149 | INFO:docling.utils.accelerator_utils:Accelerator device: 'cuda:0'
Apr 05 19:52:01.905 | INFO:docling.models.factories.base_factory:Loading plugin 'docling_defaults'
Apr 05 19:52:01.910 | INFO:docling.models.factories:Registered picture descriptions: ['vlm', 'api'] INFO:docling.pipeline.base_pipeline:Processing document wlframework.pdf
...
### Steps to reproduce
I am using this code to run docling. I only want to extract figures and tables from the pdf:
```python
extract_images_app = modal.App(name='extract_images-app')
docling_image = modal.Image.from_registry("nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04", add_python="3.10").run_commands(
"apt-get update",
"apt-get install -y software-properties-common",
"pip install PyPDF2",
"pip install docling",
"docling-tools models download",
# force_build=True
)
vol = Volume.from_name("ingestion")
@extract_images_app.function(image=docling_image, volumes={"/ingestion": vol}, gpu="L4", timeout=3600)
def extract_images(input_pdf, extract_images=True, extract_tables=True):
from docling.datamodel.document import ConversionResult
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions, TableFormerMode, AcceleratorDevice, AcceleratorOptions
from docling_core.types.doc import ImageRefMode, PictureItem, TableItem
import logging
import os
accelerator_options = AcceleratorOptions(
num_threads=256, device=AcceleratorDevice.CUDA
)
# Configure logging
logging.basicConfig(level=logging.INFO)
_log = logging.getLogger(__name__)
# Define the path where models were downloaded during image build
artifacts_path = "/root/.cache/docling/models"
pipeline_options = PdfPipelineOptions(artifacts_path=artifacts_path)
pipeline_options.do_ocr = False
pipeline_options.accelerator_options = accelerator_options
if extract_images or extract_tables:
pipeline_options.images_scale = 2.0
pipeline_options.generate_page_images = True
pipeline_options.generate_picture_images = True
if extract_tables:
pipeline_options.do_table_structure = True
pipeline_options.table_structure_options.mode = TableFormerMode.ACCURATE
doc_converter = DocumentConverter(
format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)}
)
conv_result = doc_converter.convert(input_pdf)
```
...
### Docling version
Version: 2.28.4
...
### Python version
Python 3.10
...
Contributor guide
Assessment
This issue has not been assessed yet.