Skip to content

fix(deps): make torch/torchvision installable on macOS - #193

Merged
noor-lpi merged 1 commit into
mainfrom
fix/macos-torch-install
Sep 30, 2026
Merged

noor-lpi merged 1 commit into
mainfrom
fix/macos-torch-install

Conversation

@noor-lpi

Copy link
Copy Markdown
Contributor

Problem

poetry install fails on macOS (e.g. Apple Silicon laptops), so the API can't be run locally on a Mac:

Unable to find installation candidates for torch (2.9.1+cpu)
24 wheel(s) were skipped as your project's environment does not support the identified abi tags

torch and torchvision are pinned to 2.9.1+cpu / 0.24.1+cpu from the pytorch_cpu index. PyTorch only publishes the +cpu builds for Linux (and Windows); on macOS the CPU build is simply the plain 2.9.1 wheel, so there is nothing for Poetry to install.

Fix

Declare both packages per platform in pyproject.toml:

  • Linux → +cpu from pytorch_cpu, exactly as before (Docker / staging / prod unaffected)
  • macOS → same versions (2.9.1 / 0.24.1) from PyPI

The macOS entry needs an explicit source = "pypi": without it, Poetry treats 2.9.1+cpu as satisfying 2.9.1 and still picks the Linux-only build on Mac.

About the poetry.lock diff

Re-generated with Poetry 2.2.1 (the version that produced the current lockfile). The lock has to be committed alongside pyproject.toml, otherwise poetry install refuses to run. Changes are additive only:

  • macOS entries for torch / torchvision
  • PyPI torch's CUDA dependencies (nvidia-*, triton), whose markers resolve to Linux and darwin — i.e. they are never installed on any platform
  • no existing Linux package versions change

How to test

  • macOS: poetry install then make run-poetry → /docs returns 200 (verified locally)
  • Linux / Docker: unchanged, still installs torch 2.9.1+cpu

🤖 Generated with Claude Code

torch/torchvision were pinned to the `+cpu` builds from the PyTorch CPU
index, which only publishes those builds for Linux. `poetry install`
therefore failed on macOS. Declare them per platform: Linux keeps the
`+cpu` builds (Docker/prod unchanged), macOS uses the same versions
from PyPI.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@noor-lpi noor-lpi self-assigned this Sep 29, 2026
@noor-lpi
noor-lpi merged commit 2d03615 into main Sep 30, 2026
3 checks passed
@noor-lpi
noor-lpi deleted the fix/macos-torch-install branch September 30, 2026 08:31
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.

2 participants