Skip to content

fix(docker): install CPU-only torch before easyocr - #433

Open
thakur-patel wants to merge 3 commits into
mozarkai:mainfrom
thakur-patel:fix/docker-easyocr-cpu-torch
Open

thakur-patel wants to merge 3 commits into
mozarkai:mainfrom
thakur-patel:fix/docker-easyocr-cpu-torch

Conversation

@thakur-patel

Copy link
Copy Markdown
Member

Summary

  • easyocr transitively depends on torch, and PyPI's default Linux torch wheel bundles the full CUDA toolkit as separate nvidia-* packages (cuBLAS, cuSOLVER, cuDNN, NCCL, etc). These containers only run OCR on CPU, so that's several unused GB — large enough that it filled a build host's disk mid-image-export during a real build attempt.
  • Installs the CPU-only torch/torchvision wheel from download.pytorch.org/whl/cpu before easyocr in Docker/prod/Dockerfile, Docker/mcp/prod/Dockerfile, and Docker/dev/Dockerfile, so pip/uv never resolves the CUDA variant.
  • Documents a branch-naming convention in CLAUDE.md (fix/, feat/, refactor/, etc.) mirroring the Conventional Commit types already enforced by the commit-msg hook.
  • Documents an image-tagging convention in Docker/deployment.md: tag images <optics_version>-<vision_backend> (e.g. 1.9.1-easyocr) across all four build paths, so the tag itself states what's baked into the image.

Why

A production image build from a disk-constrained host (Cloud Shell, 95G root) failed with no space left on device during image export. Root cause traced to the CUDA-enabled torch wheel pulled in transitively by easyocr — none of the CUDA libraries are used since these images run inference on CPU only.

Test plan

  • Rebuilt Docker/prod/Dockerfile locally (VISION_BACKEND=easyocr, the default) and confirmed the image builds without pulling any nvidia-* CUDA packages (torch==2.13.0+cpu, torchvision==0.28.0+cpu), and that easyocr.Reader(['en']) still initializes fine on CPU torch.
  • Repeat the same check for Docker/mcp/prod/Dockerfile and Docker/dev/Dockerfile.

easyocr transitively depends on torch, and PyPI's default Linux torch
wheel bundles the full CUDA toolkit as separate nvidia-* packages
(cuBLAS, cuSOLVER, cuDNN, NCCL, etc). These images only ever run OCR
on CPU, so the CUDA build adds several unused GB and was large enough
to fill a build host's disk mid-export. Installing the CPU-only wheel
from download.pytorch.org first keeps pip/uv from ever resolving the
CUDA variant.
Mirror the Conventional Commit types the commit-msg hook already
enforces (fix/feat/refactor/docs/chore/test/perf/style/build/ci) so
branch names carry the same signal as commit prefixes.
Recommend tagging images <optics_version>-<vision_backend> (e.g.
1.9.1-easyocr) across all four build paths so the tag itself states
what's baked into the image, instead of leaving both facts to
guesswork after the fact.
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@thakur-patel
thakur-patel requested a review from malto101 August 4, 2026 14:49
@thakur-patel
thakur-patel marked this pull request as ready for review August 4, 2026 14:49

@malto101 malto101 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
could you fix those warnings raised by sonarqube

@malto101

Copy link
Copy Markdown
Member

seems to have diverge, @thakur-patel could you rebase from main tip

@chinmayajha chinmayajha self-assigned this Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants