PennyLaneAI / qml

Introductions to key concepts in quantum programming, as well as tutorials and implementations from cutting-edge quantum computing research.
https://pennylane.ai/qml
Apache License 2.0
537 stars 185 forks source link

Fix for installation of torch and torchvision on macOS #1125

Closed austingmhuang closed 3 months ago

austingmhuang commented 3 months ago

Title: Fix for installation of torch and torchvision on macOS

Summary: After installing poetry (version 1.8.3) on macOS and running make environment, you get the following error. Fixing this error will lead to a similar one for torchvision.

  - Installing torch (1.13.1+cpu): Failed

  RuntimeError

  Unable to find installation candidates for torch (1.13.1+cpu)

  at ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/installation/chooser.py:74 in choose_for
       70│ 
       71│             links.append(link)
       72│ 
       73│         if not links:
    →  74│             raise RuntimeError(f"Unable to find installation candidates for {package}")
       75│ 
       76│         # Get the best link
       77│         chosen = max(links, key=lambda link: self._sort_key(package, link))
       78│ 

This is because the installer is using the +cpu version (despite the fact that the non +cpu version is in pyproject.toml). Specifying the source seems to fix the issue and the installer proceeds without error.

Relevant references:

Possible Drawbacks:

Related GitHub Issues: