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 1.13 cannot be installed using poetry on Mac M1 #88049

Closed
mawicks opened this issue Oct 30, 2022 · 14 comments · Fixed by DiffEqML/torchdyn#175
Closed

PyTorch 1.13 cannot be installed using poetry on Mac M1 #88049

mawicks opened this issue Oct 30, 2022 · 14 comments · Fixed by DiffEqML/torchdyn#175
Labels
module: binaries Anything related to official binaries that we release to users module: regression It used to work, and now it doesn't triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone

Comments

@mawicks
Copy link

mawicks commented Oct 30, 2022

🐛 Describe the bug

This is an installation issue.

Poetry parses the endpoint at https://pypi.org/pypi/torch/1.13/json to get dependency metadata. The endpoint returns:

"requires_dist": [
      "typing-extensions",
      "nvidia-cuda-runtime-cu11 (==11.7.99)",
      "nvidia-cudnn-cu11 (==8.5.0.96)",
      "nvidia-cublas-cu11 (==11.10.3.66)",
      "nvidia-cuda-nvrtc-cu11 (==11.7.99)",
      "opt-einsum (>=3.3) ; extra == 'opt-einsum'"
    ],

However, the packages nvidia-cuda-runtime-cu11 , nvidia-cudnn-cu11, nvidia-cuda-nvrtc-cu11, and nvidia-cuda-nvrtc-cu11 do not exist for M1, and poetry update fails with

  Unable to find installation candidates for nvidia-cublas-cu11 (11.10.3.66)
  Unable to find installation candidates for nvidia-cuda-nvrtc-cu11 (11.7.99)
  Unable to find installation candidates for nvidia-cuda-runtime-cu11 (11.7.99)
  Unable to find installation candidates for nvidia-cudnn-cu11 (8.5.0.96)

This is specific to v1.13. This problem did not exist in v1.12.1

Versions

This probably isn't relevant until after it's installed, but I get:

Collecting environment information...
PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.6 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.102)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] (64-bit runtime)
Python platform: macOS-12.6-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.982
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.4
[pip3] torch==1.13.0
[conda] Could not collect

cc @ezyang @seemethere @malfet

@atalman
Copy link
Contributor

atalman commented Oct 30, 2022

cc @malfet @seemethere

This issue maybe related to pypi repo ? I just downloaded the M1 version of wheel from pypi:

https://files.pythonhosted.org/packages/79/b3/eaea3fc35d0466b9dae1e3f9db08467939347b3aaa53c0fd81953032db33/torch-1.13.0-cp310-none-macosx_11_0_arm64.whl

I see following Metadata requirements:

Requires-Python: >=3.7.0
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: typing-extensions
Provides-Extra: opt-einsum
Requires-Dist: opt-einsum (>=3.3) ; extra == 'opt-einsum'

No mentions of the

"nvidia-cuda-runtime-cu11 (==11.7.99)",
"nvidia-cudnn-cu11 (==8.5.0.96)",
"nvidia-cublas-cu11 (==11.10.3.66)",
"nvidia-cuda-nvrtc-cu11 (==11.7.99)",

These are Linux specific requirements that should not be used in Mac M1

@malfet malfet added module: binaries Anything related to official binaries that we release to users module: regression It used to work, and now it doesn't triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 30, 2022
@malfet
Copy link
Contributor

malfet commented Oct 30, 2022

Dependencies to linux package should have ; platform_system=="Linux" suffix to make it more friendly to poetry

@willfrey
Copy link
Contributor

willfrey commented Oct 31, 2022

FWIW, this also affects Macs with Intel chips because (at a minimum), nvidia-cuda-nvrtc-cu11 does not supply any Mac wheels on PyPI. Hence, Poetry goes out and finds nothing and throws a RuntimeError about installing torch 1.13.0.

Specifying the ; platform_system=="Linux" should address this for Intel Macs, though.

seanwu1105 added a commit to seanwu1105/interactive-concept-bottleneck that referenced this issue Nov 3, 2022
seanwu1105 added a commit to seanwu1105/interactive-concept-bottleneck that referenced this issue Nov 3, 2022
@neersighted
Copy link

The issue here is that Poetry does not support split metadata across wheels; instead, markers should be used with unified metadata. This is not just a Poetry decision; PyPI's metadata API currently gathers metadata from the first distfile to be uploaded. Until such time that PEP 658 is implemented in PyPI, having inconsistent metadata between distfiles is likely to confuse non-Pip tools.

@MartinBubel
Copy link

torch>1.12 also can't be installed on Windows with Intel Chip. pip and conda installatoin works fine however. Also, torch<1.13 installation via poetry works. This might not be a torch issue and seems to be related how poetry chooses the wheel files but I just wanted to mention that it might be a workaround for someone looking for this to limit torch<1.13 if poetry is mandatory.

@mawicks
Copy link
Author

mawicks commented Nov 3, 2022

I was really looking to get the improved M1 support in 1.13. For now, my work-around is to hard-code a path to the wheel in pyproject.toml:

[tool.poetry.dependencies]
torch = {url = "https://files.pythonhosted.org/packages/79/b3/eaea3fc35d0466b9dae1e3f9db08467939347b3aaa53c0fd81953032db33/torch-1.13.0-cp310-none-macosx_11_0_arm64.whl"}

It seems that the PyPi API doesn't support different requirements on different platforms.

@JacobHayes
Copy link
Contributor

I submitted #88826 to address this for future releases. 🤞

It doesn't solve the larger issue @neersighted mentioned of split metadata across wheels, but should at least have the platform marker. I guess the opposite problem of Poetry inspecting metadata for one of the non-Linux wheels and thus omitting these Linux deps on Linux systems might be possible (I'm not sure if the order the wheels are picked is deterministic?).

@neersighted
Copy link

It's based on the order we get them back from PyPI (and PyPI uses upload order iirc; this is modeled on the fact that the PyPI JSON API uses the first artifact to be uploaded).

@bitliner
Copy link

atalman pushed a commit to atalman/pytorch that referenced this issue Nov 30, 2022
…8826)

Fixes pytorch#88049

pytorch#85097 added new extra dependencies on `nvidia-*`. They are linux (GPU) only packages, but were not marked as such, causing issues installing pytorch 1.13 via Poetry (and possibly other tools that follow PyPI's metadata API) on non-Linux systems. This "fixes" the issue by adding the `; platform_system = 'Linux'` marker on these dependencies, but the main problem of different metadata for different wheels is a [somewhat larger issue](pytorch#88049 (comment)).

pytorch#85097 used `;` as a delimiter for splitting the different deps, but that is the delimiter used in markers, so I changed to split on `|`.

Pull Request resolved: pytorch#88826
Approved by: https://github.com/neersighted, https://github.com/lalmei, https://github.com/malfet
atalman pushed a commit to atalman/pytorch that referenced this issue Dec 6, 2022
…8826)

Fixes pytorch#88049

pytorch#85097 added new extra dependencies on `nvidia-*`. They are linux (GPU) only packages, but were not marked as such, causing issues installing pytorch 1.13 via Poetry (and possibly other tools that follow PyPI's metadata API) on non-Linux systems. This "fixes" the issue by adding the `; platform_system = 'Linux'` marker on these dependencies, but the main problem of different metadata for different wheels is a [somewhat larger issue](pytorch#88049 (comment)).

pytorch#85097 used `;` as a delimiter for splitting the different deps, but that is the delimiter used in markers, so I changed to split on `|`.

Pull Request resolved: pytorch#88826
Approved by: https://github.com/neersighted, https://github.com/lalmei, https://github.com/malfet
atalman added a commit that referenced this issue Dec 6, 2022
…89924)

Fixes #88049

#85097 added new extra dependencies on `nvidia-*`. They are linux (GPU) only packages, but were not marked as such, causing issues installing pytorch 1.13 via Poetry (and possibly other tools that follow PyPI's metadata API) on non-Linux systems. This "fixes" the issue by adding the `; platform_system = 'Linux'` marker on these dependencies, but the main problem of different metadata for different wheels is a [somewhat larger issue](#88049 (comment)).

#85097 used `;` as a delimiter for splitting the different deps, but that is the delimiter used in markers, so I changed to split on `|`.

Pull Request resolved: #88826
Approved by: https://github.com/neersighted, https://github.com/lalmei, https://github.com/malfet

Co-authored-by: Jacob Hayes <jacob.r.hayes@gmail.com>
@hongbo-miao
Copy link

hongbo-miao commented Dec 9, 2022

Met same issue, was trying based on some solutions in this post:

[tool.poetry.dependencies]
torch = {version = "1.13.0", source = "pytorch"}

[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl"
default = false
secondary = true

but no luck.

I end up with a solution similar to @mawicks :

[tool.poetry.dependencies]
python = "3.10.x"
torch = {url = "https://download.pytorch.org/whl/cpu/torch-1.13.0-cp310-none-macosx_11_0_arm64.whl"}

You can find all versions at either one of

(No support for Python 3.11 of macOS with M1 chip (arm64) at the time of writing this post)

@jspaezp
Copy link

jspaezp commented Dec 9, 2022

Seems like the fix has been added to torch 1.13.1, which right now is in release candidate stage
#89855

merge of the fix into torch:
#89855 (comment)

kulinseth pushed a commit to kulinseth/pytorch that referenced this issue Dec 10, 2022
…8826)

Fixes pytorch#88049

pytorch#85097 added new extra dependencies on `nvidia-*`. They are linux (GPU) only packages, but were not marked as such, causing issues installing pytorch 1.13 via Poetry (and possibly other tools that follow PyPI's metadata API) on non-Linux systems. This "fixes" the issue by adding the `; platform_system = 'Linux'` marker on these dependencies, but the main problem of different metadata for different wheels is a [somewhat larger issue](pytorch#88049 (comment)).

pytorch#85097 used `;` as a delimiter for splitting the different deps, but that is the delimiter used in markers, so I changed to split on `|`.

Pull Request resolved: pytorch#88826
Approved by: https://github.com/neersighted, https://github.com/lalmei, https://github.com/malfet
@chanansh
Copy link

I am using mac for local development and a docker for publishing. The following allowed me to use a single pyproject file for both, hope it will help someone:

torch = [{markers = "sys_platform == 'macos'", url = "https://download.pytorch.org/whl/cpu/torch-1.13.0-cp310-none-macosx_11_0_arm64.whl"},
{markers = "sys_platform == 'linux'", url="https://download.pytorch.org/whl/torch-1.13.0-cp310-cp310-manylinux2014_aarch64.whl"}]

jonahpearl added a commit to jonahpearl/top-bottom-moseq that referenced this issue Feb 6, 2023
Torch 1.13 has some weird extra NVIDIA dependencies, described [here] (pytorch/pytorch#88049), which don't seem to recognize that cuda is loaded as a module. So as it currently stands, you need to install top-bottom and then uninstall those nvidia packages, and then maybe muck around a bit more so that everything points to the right place. I don't see any issue with pinning torch 1.12 for now.
@KimSoungRyoul
Copy link

#88049 (comment)

2023 current macOS platform name is "darwin" (maybe It's probably been around for a while.e )

>>> import sys
>>> sys.platform
'linux'

>>> import sys
>>> sys.platform 
'darwin' # macos m1

so it will be better work in local macOS m1 (~m3)
I hope it will help someone too

[tool.poetry.dependencies]
python = "3.10.9"
torch = [
    { markers = "sys_platform == 'darwin'", url = "https://download.pytorch.org/whl/cpu/torch-1.13.1-cp310-none-macosx_11_0_arm64.whl#sha256=0122806b111b949d21fa1a5f9764d1fd2fcc4a47cb7f8ff914204fd4fc752ed5" },
    { markers = "sys_platform == 'linux'", url = "https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014" }
]

@slashtechno
Copy link

slashtechno commented Dec 27, 2023

The issue was closed as completed, but it seems, both from comments on this issue and my experience, that this issue remains. What's the recommended way to avoid installing CUDA related dependencies on MacOS but installing them on Linux?
Currently, I have the following:

torch = ">=2.0.0, !=2.0.1, !=2.1.0"

Is it possible to specify the URL for MacOS but use the default on every other platform, as this problem seems to only be apparent on MacOS?

pytorchmergebot pushed a commit that referenced this issue Mar 4, 2024
Follow up on: #102604
Address this comment: #102604 (comment)

Whl metadata for all wheels published to pypi must match, otherwise poetry install will fail see this comment:
#88049 (comment)

Pull Request resolved: #121014
Approved by: https://github.com/malfet
Lourencom pushed a commit to Lourencom/pytorch that referenced this issue Mar 6, 2024
Follow up on: pytorch#102604
Address this comment: pytorch#102604 (comment)

Whl metadata for all wheels published to pypi must match, otherwise poetry install will fail see this comment:
pytorch#88049 (comment)

Pull Request resolved: pytorch#121014
Approved by: https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: binaries Anything related to official binaries that we release to users module: regression It used to work, and now it doesn't triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
14 participants