Skip to content

Commit

Permalink
Fix for installation of torch and torchvision on macOS (#1125)
Browse files Browse the repository at this point in the history
**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:**

---------

Co-authored-by: Rashid N H M <[email protected]>
  • Loading branch information
austingmhuang and rashidnhm committed Jun 17, 2024
1 parent bdc574c commit 364a5a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ stim = "*"

# Install a difference version of torch from PyPI as the one from PyTorch repo is not compatible with MacOS
torch = [
{ version = "1.13.1", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" },
{ version = "1.13.1", source="pypi", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" },
{ version = "1.13.1+cpu", source = "pytorch-cpu", markers = "platform_machine == 'x86_64'" }
]
torchvision = [
{ version = "0.14.1", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" },
{ version = "0.14.1", source="pypi", markers = "sys_platform == 'darwin' and platform_machine == 'arm64'" },
{ version = "0.14.1+cpu", source = "pytorch-cpu", markers = "platform_machine == 'x86_64'" }
]

Expand Down

0 comments on commit 364a5a7

Please sign in to comment.