Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytorch cannot be installed from cpu index when opencv is also a dependency #11558

Closed
Dronakurl opened this issue Feb 16, 2025 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Dronakurl
Copy link

Summary

When following the instructions on using uv with pytorch on the astral website, I encounter an error when adding opencv.

I get the error

3.807 error: Distribution `torch==2.6.0 @ registry+https://download.pytorch.org/whl/cpu` can't be installed because it doesn't have a source distribution or wheel for the current platform
3.807
3.807 hint: You're on Linux (`manylinux_2_36_x86_64`), but `torch` (v2.6.0) only has wheels for the following platform: `macosx_11_0_arm64`

Here is the Dockerfile with minimal example that produces this error. Without opencv-python, it works, so torch is installed.
I read #11406, but could not find anything that helps me with that.

FROM ghcr.io/astral-sh/uv:0.5.24-debian-slim

COPY <<EOF /mre/pyproject.toml
[project]
name = "project"
version = "0.1.0"
requires-python = "==3.12.0"
dependencies = [
  "torch>1.13.1'",
  "torchvision>=0.14.1",
  "opencv-python",
]

[tool.uv.sources]
torch = [{ index = "pytorch-cpu" }]
torchvision = [{ index = "pytorch-cpu" }]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
EOF

WORKDIR /mre
RUN uv  sync -U 

Run with
docker build -t uvdebug . --progress plain --no-cache

Platform

Ubuntu 24.04, x86_64

Version

uv 0.6.0

Python version

Python 3.12.3

@Dronakurl Dronakurl added the bug Something isn't working label Feb 16, 2025
@charliermarsh
Copy link
Member

I fixed this on main in #11546.

@charliermarsh charliermarsh self-assigned this Feb 16, 2025
@Dronakurl
Copy link
Author

Thank you very much! I missed the other issue in my search.

@charliermarsh
Copy link
Member

No worries, it's not at all obvious that it's the same issue, I just learned when debugging that it was also triggered by OpenCV in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants