fix(ocr): increase memory limit to 10GB, reduce render DPI to 200
Some checks failed
CI / Unit & Component Tests (push) Failing after 1s
CI / Backend Unit Tests (push) Failing after 0s
CI / Unit & Component Tests (pull_request) Failing after 0s
CI / Backend Unit Tests (pull_request) Failing after 1s

Surya 0.17 models use ~5GB idle. At 300 DPI on a multi-page PDF,
page images + inference tensors push past the 6GB limit, causing
OOM kills during 'Detecting bboxes'. Increased to 10GB and reduced
render DPI to 200 (still sufficient for OCR, uses ~44% less memory).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-12 22:20:36 +02:00
parent 4500c99e40
commit 7f78bc9cf4
2 changed files with 5 additions and 4 deletions

View File

@@ -78,8 +78,8 @@ services:
dockerfile: Dockerfile
container_name: archive-ocr
restart: unless-stopped
mem_limit: 6g
memswap_limit: 6g
mem_limit: 10g
memswap_limit: 10g
volumes:
- ocr_models:/app/models
environment:

View File

@@ -92,8 +92,9 @@ async def _download_and_convert_pdf(url: str) -> list[Image.Image]:
for page_idx in range(len(pdf)):
page = pdf[page_idx]
# Render at 300 DPI for good OCR quality
bitmap = page.render(scale=300 / 72)
# Render at 200 DPI — balances OCR quality vs memory usage
# (Surya 0.17 models use ~5GB idle; 300 DPI causes OOM on multi-page docs)
bitmap = page.render(scale=200 / 72)
pil_image = bitmap.to_pil()
images.append(pil_image)