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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "module compiled against ABI version" when using a device on MacBook Pro M2 with MacOS Sonoma 14.4 #122056
Comments
[Edit] Indeed PyTorch build against Numpy-2.0 release candidate is backward compatible with Numpy-1.X Let's test it throughout our config permutations: #122157 |
@trevorstr as comment message says, your workaround is to uninstall numpy (or install nunmpy 1.x) |
@trevorstr We are currently working on enabling numpy 2.x on our CI/CD, tracked here: #107302 |
I'm confused though, because I didn't install numpy 2.x specifically. It must have been automatically installed when I ran the pip command to install Does that mean that the PyTorch package is referencing the wrong version of numpy in its dependencies? |
|
That makes perfect sense, thank you for helping me understand why that occurred. I can confirm that uninstalling numpy 2.x, and installing the latest version of 1.x explicitly, the code now works.
Feel free to close this ticket if you want, or leave it open since you're working on integrating numpy 2.x. Thank you |
Actually, not sure there is anything we want to fix this, as neither of those are an errors, but rather a warnings, albeit an annoying ones |
I'll note that the verbose warning is due to The likely next things to happen are:
|
@rgommers but is it safe to assume, that if one to build using current version of PyBind and numpy-2.0.0b1 API, it will be both forward compatible with the upcoming 2.0.0 and backward compatible with 1.x? Or it's better to constrain PyTOrch-2.3 to NumPy-1.x? |
I think not. There is two parts to that:
For (2), Pybind11 accesses API (e.g., https://github.com/pybind/pybind11/blob/v2.11/include/pybind11/numpy.h#L266) that may disappear or start raising.
As of right now, yes, it'd be safer to have a runtime dependency I understand that there is some risk to doing something like that so late in the release cycle, since |
But we are not querying any NumPy APIs thru PyBind, so that shouldn't be a problem.
Tricky part is: PyTorch does not depend on NumPy, but say TorchVision does. So we can put a constraint there, but as you've said it just results in us installing older versions of Torch, which is not ideal |
Ah okay, then it's perhaps safer - but hard to be sure without trying. I'd say that if you see the warning in the issue description ( pytorch/torch/csrc/utils/tensor_numpy.cpp Lines 64 to 85 in d2a8d38
is_numpy_available returns false , and numpy interop will not work.
|
Agreed. That won't work well in practice. Maybe we should give it a few days, and see if the needed |
@rgommers Nightly change for wheels just landed: pytorch/builder@65f8e7d We can test these tomorrow morning. Is there particular smoke test or anything like this we can run to test if it works correctly ? |
Great! ABI compat should be fine; if not a very basic test like this should catch it: import torch
import numpy as np # with numpy 1.26 for example
x = np.arange(5)
t = torch.tensor(x)
That's ABI compat; doesn't mean any regular Python API usage is 100% fine (it probably is), but a regular test suite run in an env with the nightly and numpy 2.0.0b1 will turn that up soon enough. |
Quick update: Pybind11 |
Pybind11 2.12.0 is out now: https://pypi.org/project/pybind11/2.12.0/. Upgrading to that will fix this issue. |
@trevorstr I'll reopen this, the upgrade actually does need to happen in the |
Cool, thank you! I appreciate you taking ownership and driving the resolution. |
To fix #122056 Building with NP 2.0 allows me to run locally with both NP 2.0 and 1.26. Any other test we should run @rgommers ? FYI @Skylion007 @atalman Pull Request resolved: #122899 Approved by: https://github.com/Skylion007 (cherry picked from commit 6c2f36c)
To fix #122056 Building with NP 2.0 allows me to run locally with both NP 2.0 and 1.26. Any other test we should run @rgommers ? FYI @Skylion007 @atalman Pull Request resolved: #122899 Approved by: https://github.com/Skylion007 (cherry picked from commit 6c2f36c) Co-authored-by: albanD <desmaison.alban@gmail.com>
To fix pytorch#122056 Building with NP 2.0 allows me to run locally with both NP 2.0 and 1.26. Any other test we should run @rgommers ? FYI @Skylion007 @atalman Pull Request resolved: pytorch#122899 Approved by: https://github.com/Skylion007
馃悰 Describe the bug
When I run the code, I get this error:
How can I go about resolving this?
Versions
cc @seemethere @malfet @osalpekar @atalman @mruberry @rgommers @kulinseth @albanD @DenisVieriu97 @razarmehr
The text was updated successfully, but these errors were encountered: