From 37abc376ec01847638314fe6f05cc352f559fd24 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 12 Apr 2026 19:46:37 +0200 Subject: [PATCH] fix(ocr): install torchvision from CPU index alongside torch torchvision installed from PyPI expects CUDA torch operator registrations. Installing from the CPU whl index ensures torchvision matches the CPU-only torch build. Fixes 'torchvision::nms does not exist' RuntimeError on startup. Co-Authored-By: Claude Sonnet 4.6 --- ocr-service/Dockerfile | 2 ++ ocr-service/requirements.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/ocr-service/Dockerfile b/ocr-service/Dockerfile index 57368726..99ac88fc 100644 --- a/ocr-service/Dockerfile +++ b/ocr-service/Dockerfile @@ -9,8 +9,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # PyTorch CPU-only — separate layer; the whl/cpu index strips all CUDA variants (~2 GB saved) +# torchvision must also come from the CPU index to match torch's operator registrations RUN pip install --no-cache-dir \ torch==2.7.1 \ + torchvision==0.22.1 \ --index-url https://download.pytorch.org/whl/cpu COPY requirements.txt . diff --git a/ocr-service/requirements.txt b/ocr-service/requirements.txt index 5337edef..7ee1d67a 100644 --- a/ocr-service/requirements.txt +++ b/ocr-service/requirements.txt @@ -2,6 +2,7 @@ fastapi[standard]==0.115.6 surya-ocr==0.17.1 kraken==7.0 torch==2.7.1 +torchvision==0.22.1 transformers>=4.56.1,<5.0.0 pillow>=10.2.0,<11.0.0 pypdfium2==4.30.0