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
Buggy Accelerate Backend when using numpy 1.19 #15947
Comments
This is by design. Did you read the error message? Is it unclear? |
so how can I fix this error, by updating the Accelerate backend? I had a search and don't think I can update that for my MacOS. |
@billlyzhaoyh Requesting to use OpenBLAS while building on MacOS instead. Use site.cfg in the root repo directory to build using the same. |
Closing. We strongly recommend not using Accelerate. |
Sure, how do we not use it? I got the same error when just run simple |
If you are building your own NumPy, get OpenBlas. You can use |
I am definitely not building on my own. I am using macOS, and run |
Pip can build from source behind your back. If it takes more than a few seconds to install, it may be compiling. To force pip to only use binary wheels and never compile, use
Can you try to uninstall your numpy and install with the |
This fixed the problem for me. (I replaced EDIT: Pasting complete solution in case gist gets deleted :)
|
A slightly simpler solution:
Per https://twitter.com/pradyunsg/status/1317081239526936576?s=20 this can now be done with a built-in $ pip cache remove numpy
$ brew install openblas # make sure OpenBLAS is installed
$ # activate your pypy3 virtualenv
$ OPENBLAS="$(brew --prefix openblas)" pip install numpy # let numpy's setup.py know where OpenBLAS is installed This has the added benefit that the wheel will not need to be rebuilt, and any future |
Workarounds aside though, why is the default build behavior to produce a broken wheel that can't even |
Trying to import after the build sounds like a good idea. |
Why not simply refuse to build on macOS if openblas is not found? |
There are various valid blas backends, besides OpenBLAS. The only invalid one is Accelerate. Unfortunately, macOS does not provide a way to tell us that they are providing Accelerate, we can only detect it at runtime by triggering a known bad calculation. If you can figure out how to detect Accelerate earlier that would be great. The best we had so far is to detect a symlink, but that is very fragile. |
If any python-poetry users come across this thread, I would just like to add that @glyph's solution works as well if you just replace the last line with |
I've tried a previous version of numpy and it worked for me Hope this help |
uninstall and install 1.18.0 -- worked for me! kuddos to the above ^^ |
I'm here to report that the suggestion to use openblas doesn't work. This crashes:
while this works without any issues:
|
@fny check the output to see if pip is using a cached wheel. You might have to clear the cache in that case. |
@fny see #15947 (comment) for updated instructions |
Building NumPy from source with default options of builder causes it to link against Accelerate framework which is buggy and raises a warning mentioned in [2]. "RankWarning: Polyfit may be poorly conditioned" Accelerate is deprecated with NumPy 1.20+.[1] So either we build OpenBLAS in dependencies also and set appropriate env variables suggested in [1] while building NumPy for it to find OpenBLAS. Or download NumPy wheel from pip and never allow pip to build NumPy from source while installing. After this change, pip wheels are used for NumPy for macOS with x86_64. [1] https://numpy.org/doc/stable/user/building.html#lapack [2] numpy/numpy#15947 Reviewed By: #platform_macos, sebbas Differential Revision: https://developer.blender.org/D10368
Same here. Strange this is that this seems like a random condition. On some interpreter starts it works, on some it doesn't. :-(
Downgrading to |
This reverts commit df5c44b.
For issue: ``` RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, more information is available at https://numpy.org/doc/stable/user/building.html#accelerated-blas-lapack-libraries Otherwise report this to the vendor that provided NumPy. ``` Since PyPy builds a new numpy wheel on the fly. numpy/numpy#15947 (comment)
For issue: ``` RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, more information is available at https://numpy.org/doc/stable/user/building.html#accelerated-blas-lapack-libraries Otherwise report this to the vendor that provided NumPy. ``` Since PyPy builds a new numpy wheel on the fly. numpy/numpy#15947 (comment)
This commit is the next in a commit chain improving our GitHub Actions-based continuous integration (CI) configuration to install optional test-time dependencies. Specifically, this commit attempts to circumvent installation woes induced by Apple's patently broken "Accelerate" BLAS replacement (as documented at numpy/numpy#15947) by conditionally installing `pip` packages with `--force-reinstall` under macOS. This will almost certainly fail. CI gonna CI. (*Unprecedented antecedents!*)
This commit is the next in a commit chain improving our GitHub Actions-based continuous integration (CI) configuration to install optional test-time dependencies. Specifically, this commit attempts to circumvent installation woes induced by Apple's patently broken "Accelerate" BLAS replacement (as documented at numpy/numpy#15947) by conditionally installing `pip` packages with `--force-reinstall` under macOS. This will almost certainly fail. CI gonna CI. (*Wrongly elongated thongs!*)
This commit is the next in a commit chain improving our GitHub Actions-based continuous integration (CI) configuration to install optional test-time dependencies. Specifically, this commit attempts to circumvent installation woes induced by Apple's patently broken "Accelerate" BLAS replacement (as documented at numpy/numpy#15947) by conditionally avoiding installation of `pip` packages built against "Accelerate" under PyPy. Whereas forcing `pip` to reinstall these packages with `--force-reinstall` succeeds under CPython, the same approach fails to improve matters under PyPy for unknown reasons. We are short on sanity and even shorter on time, so the only remaining option is to nuke these packages from orbit under macOS + PyPy -- which is such an outlier edge-case to begin with that it seems doubtful anyone will care. We care, of course. But you can only do so much when your core platform is fundamentally broken. Thanks, Apple. (*Drip-fed metalhead!*)
* update github wheel building workflow * update documentation building config to Python 3.9 * also test on Python 3.9 in the Azure CI environment * revert too recent python version for readthedocs (set to 3.8) * apply idea from numpy/numpy#15947 (comment) * Revert "apply idea from numpy/numpy#15947 (comment)" This reverts commit df5c44b. * apply idea from scipy/scipy#13409 (comment) * attempt other OPENBLAS fix * document change
This release brings undeniable support for **typed NumPy arrays** (i.e., `numpy.typed.NDArray` type hints), **typing backports** (i.e., public public attributes of the third-party `typing_extensions` package, enabling typing_ types introduced by newer Python versions to be used under older Python versions), and **portable beartype validators** (i.e., `beartype.vale` type hints usable under *all* Python versions via the `typing_extensions.Annotated` backport). This release resolves **4 issues** and merges **2 pull requests.** Changes include: ## Compatibility Improved * **Typed NumPy arrays** (i.e., `numpy.typed.NDArray` type hints). The `@beartype` decorator now transparently supports the third-party `numpy.typing.NDArray` type hint newly introduced by NumPy >= 1.21.0, resolving issue #42 kindly submitted by NumPy extraordinaire @Antyos. Note that usage of typed NumPy arrays under Python < 3.9.0 requires installation of the third-party `typing-extensions` package, which `@beartype` will then automagically detect and leverage internally. * **Typing backports** (i.e., `typing_extensions` type hints). The `@beartype` decorator now transparently supports all public type hints of the third-party `typing_extensions` package, resolving issue #34 kindly submitted by Ryan Soklaski (@rsokl) of considerable *MIT Beaver Works Summer Institute* and *Python Like You Mean It* fame. Note that usage of typed NumPy arrays under Python < 3.9.0 requires installation of the third-party `typing-extensions` package, which `@beartype` will then automagically detect and leverage internally. * **Python < 3.9.0 beartype validators.** The `@beartype` decorator now portably supports **beartype validators** (i.e., `beartype.vale` objects annotating `typing{_extensions}.Annotated` type hints) across all Python versions, *also* resolving issue #34 kindly submitted by Ryan Soklaski (@rsokl). <sup>hallowed be his username</sup> Note that usage of beartype validators under Python < 3.9.0 requires: * Installation of the third-party `typing-extensions` package. * Annotation of `beartype.vale` objects by `typing_extensions.Annotated` (rather than `typing.Annotated`). * **Python >= 3.10.0 `typing.NewType` type hints.** This release resolves a minor incompatibility recently introduced by Python 3.10.0rc1, which (*waitforit*) broke backward compatibility with prior implementations of the public `typing.NewType` type hint. Previously, that hint was implemented as a closure; Python ≥ 3.10 fundamentally refactored that hint to a pure-Python class instance – significantly complicating cross-version detection. *yuwastemytime,* CPython? * **Binary dunder method return annotations** (i.e., dunder methods accepting exactly two arguments). Previously, `@beartype` adopted mypy's permissive approach of implicitly coercing the return annotations of binary dunder methods returning only booleans to instead return `typing.Union[bool, type(NotImplemented)]`. `beartype` now expands that approach to *all* binary dunder methods regardless of return annotation. Thanks to pull request #40 from Matt Bogosian (@posita), Dropbox's positive code genius! ## Compatibility Broken * **None.** This release preserves backward compatibility with the prior stable release. ## Issues Resolved * **#44,** documenting beartype's new project shield generously ginned up by Matt Bogosian (@posita), Dropbox's positive code genius. * **#42,** enabling typed NumPy arrays to be used under both Python ≥ 3.9.0 natively *and* Python < 3.9.0 via the `typing_extensions.Annotated` backport. * **#40,** including: * **Fake builtin types** (i.e., non-builtin classes erroneously masquerading as builtin). Previously, `@beartype` incorrectly generated syntactically invalid code for decorated callables annotated by one or more fake builtin types – which, miraculously, there are hardly any of. Still... *it's not a good look, beartype.* Thanks to Matt Bogosian (@posita), Dropbox's positive code genius, for first detecting this horrifying edge case in pull request #40. * **#34,** enabling beartype validators to be used under Python < 3.9.0 via the `typing_extensions.Annotated` backport. ## Documentation Revised * **Badge** (i.e., shield intended for display by downstream projects). Our front-facing `README.rst` documentation now provides a post-installation advisory suggesting public declaration of @beartype project compatibility with reST- and Markdown-friendly text exhibiting a beautiful @beartype badge. Unsurprisingly, @posita made that too... because what doesn't @posita do? Nuthin'! I'm pretty sure that means @posita does everything. ## Tests Improved * **Optional dependencies.** Our GitHub Actions-based continuous integration (CI) configuration now installs optional test-time dependencies. Although `beartype` has *no* mandatory runtime dependencies, fully exercising all tests necessitates installing these test-time dependencies: * mypy, enabling tests for mypy-based PEP 561 compliance. * NumPy, enabling tests for `numpy.typing.NDArray` type hints. This proved surprisingly non-trivial. Apple's patently broken "Accelerate" BLAS replacement (as documented at numpy/numpy#15947) blocks NumPy ≥ 1.18.0 installation under default CI configurations, necessitating that we: * Only conditionally install `pip` packages with `--force-reinstall` under macOS. CI gonna CI. * Avoid installing NumPy altogether under macOS + PyPy, where even the `--force-reinstall` option fails to improve matters. You can only do so much when your core platform is fundamentally broken. Thanks, Apple. * `typing_extensions`, enabling tests for `typing` attributes unavailable under the active Python interpreter. Thanks yet again to Badge Connoisseur @posita for his tremendous efforts – which we are now eternally indebted to and can only repay across the span of several gruelling lifetimes. "It will all be worth it," I tell my future self. (*Clogged clogs and unlogged cogs!*)
Mac Catalina 10.15.7 / Python 3.10.0 / Numpy Running
so I presume there are no prebuilt wheels.
and that worked, so many thanks @fny ! |
Numpy 1.19 cannot import due to run time error in MacOS 10.14.6. Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
Reproducing code example:
Error message:
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
Traceback (most recent call last):
File "/Users/billyzhaoyh/anaconda/envs/simulation/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Users/billyzhaoyh/anaconda/envs/simulation/lib/python3.7/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/Users/billyzhaoyh/Desktop/Simulation/reina-model/calc/init.py", line 1, in
from .utils import calcfunc
File "/Users/billyzhaoyh/Desktop/Simulation/reina-model/calc/utils.py", line 9, in
from utils.quilt import load_datasets
File "/Users/billyzhaoyh/Desktop/Simulation/reina-model/utils/quilt.py", line 4, in
import quilt
File "/Users/billyzhaoyh/anaconda/envs/simulation/lib/python3.7/site-packages/quilt/init.py", line 87, in
from .tools.command import (
File "/Users/billyzhaoyh/anaconda/envs/simulation/lib/python3.7/site-packages/quilt/tools/command.py", line 24, in
import numpy as np
File "/Users/billyzhaoyh/Desktop/Simulation/reina-model/src/numpy/numpy/init.py", line 286, in
raise RuntimeError(msg)
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
Numpy/Python version information:
Python 3.7.6
Numpy -e git+https://github.com/numpy/numpy.git@078ac01a85c4db46e7f148829c2e0d0e0f30c36f#egg=numpy
The text was updated successfully, but these errors were encountered: