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

QST: Install from source without blas with pip #24703

Closed
snowman2 opened this issue Sep 14, 2023 · 21 comments · Fixed by #25063
Closed

QST: Install from source without blas with pip #24703

snowman2 opened this issue Sep 14, 2023 · 21 comments · Fixed by #25063
Labels
32 - Installation Problems installing or compiling NumPy 33 - Question Question about NumPy usage or development

Comments

@snowman2
Copy link

When trying out latest release candidate:

From: pyproj4/pyproj#1330 (comment)

Is there an environment variable you can set to not require blas when installing numpy?

/meson.build:207:4: ERROR: Problem encountered: No BLAS library detected! Install one, or use the `allow-noblas` build option (note, this may be up to 100x slower for some linear algebra operations).
@mattip
Copy link
Member

mattip commented Sep 14, 2023

Is this a duplicate of #24704? I think the problem is that the project has a test dependency on NumPy and ends up building from source instead of using pre-built wheels.

@rgommers
Copy link
Member

rgommers commented Sep 14, 2023

Besides the "wheels are coming", the answer to the question when you build from source is (as hinted at in the error message) that this works:

$ # the -C syntax requires pip 23.1; for older pip versions replace it with --config-settings=
$ pip install numpy -C-Dallow-noblas=true
$ # or with pypa/build from a local repo
$ python -m build -C-Dallow-noblas=true

There is no environment variable to do the same thing. We may relax the requirement for having BLAS installed, but I think it'd be good to see how many people find the current state a problem with the final 1.26.0 release which will include 32-bit Windows wheels.

@rgommers rgommers added 33 - Question Question about NumPy usage or development 32 - Installation Problems installing or compiling NumPy labels Sep 14, 2023
@rgommers
Copy link
Member

While the question is answered, let's leave this issue open until at least a week after the 1.26.0 release date, so it's easier to discover for others.

@snowman2
Copy link
Author

Thanks for the responses 👍

Is this a duplicate of #24704?

These failures are different because they are for pypy builds and for the i686 architecture. If the wheels are coming, this shouldn't be an issue.

@snowman2
Copy link
Author

For anyone who runs into this - based on:

This is the syntax for pip:

python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true" 

@aptalca
Copy link

aptalca commented Sep 19, 2023

We may relax the requirement for having BLAS installed, but I think it'd be good to see how many people find the current state a problem with the final 1.26.0 release which will include 32-bit Windows wheels.

This will be an issue for aarch64 users on musl based systems as numpy does not provide binary wheels for that. We (linuxserver.io) are facing that issue on our docker images that are alpine based with aarch64 images

@rgommers
Copy link
Member

@aptalca thanks for that comment. To make sure I'm understanding it right: are you saying that you're seeing failed builds and that's a problem, or also that it's fine to avoid the failed builds by default by building fallback linear algebra routines that may be ~50x slower?

@aptalca
Copy link

aptalca commented Sep 19, 2023

Sorry, I should have clarified.

We are seeing failed builds due to the newly enforced openblas requirement. Previously, numpy would build without openblas just fine. Now we have to either add openblas or add the build argument to allow building without openblas.

In most cases (for us) the speed difference is not noticeable as the apps we build don't rely on complex calculations.

milesgranger added a commit to milesgranger/crick that referenced this issue Sep 21, 2023
milesgranger added a commit to dask/crick that referenced this issue Sep 21, 2023
* Update wheels.yml workflow to run on release event

* Retry build failure [empty]

* Try installing blas before builds

* Allow numpy w/o BLAS in builds

Ref: numpy/numpy#24703

* Fixup
@Itsmittyhere
Copy link

I am trying to install:
~/klippy-env/bin/pip install -v numpy

I get this error:
Library m found: YES
Found CMake: /usr/bin/cmake (3.18.4)
WARNING: CMake Toolchain: Failed to determine CMake compilers state
Run-time dependency openblas found: NO (tried pkgconfig and cmake)
Run-time dependency openblas found: NO (tried pkgconfig and cmake)

../../numpy/meson.build:207:4: ERROR: Problem encountered: No BLAS library detected! Install one, or use the allow-noblas build option (note, this may be up to 100x slower for some linear algebra operations).

A full log can be found at /tmp/pip-install-gmgwihuj/numpy_9524064cd0ae4863b894d750518a40a5/.mesonpy-utl0nn8j/build/meson-logs/meson-log.txt
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /home/pi/klippy-env/bin/python /home/pi/klippy-env/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp2fcjefqc
cwd: /tmp/pip-install-gmgwihuj/numpy_9524064cd0ae4863b894d750518a40a5
Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

[notice] A new release of pip is available: 23.2 -> 23.2.1
[notice] To update, run: python -m pip install --upgrade pip
pi@voron:~ $

I tried to do this python update, but apparently it doesn't update either. I have no idea what to do.
Thanks in advance.

@mattip
Copy link
Member

mattip commented Sep 22, 2023

@Itsmittyhere what version of python are you using on what platform? Do you intend to build from source? You need to install the development version of a BLAS library.

@fuglede
Copy link
Contributor

fuglede commented Sep 22, 2023

FWIW: I ran into this one while using cibuildwheel to build a package that relies on NumPy. Based on your discussion, I have to imagine there's some way of configuring setup.cfg to specify "allow-noblas" somehow, but since I have no particular need for supporting PyPy/i686, I could get around it by adding

[tool.cibuildwheel]
skip = ["pp*", "*i686"]

to pyproject.toml.

@rgommers
Copy link
Member

Thanks for the comment @fuglede. Using numpy as a build dependency on platforms for which we don't publish wheels is a tricky one, and perhaps the best reason so far to go back to allow-noblas=true.

There's no config file or environment variable to set that can address this I believe. The way to do it would be to call pip install numpy -C-Dallow-noblas=true in the "before build" stage of the cibuildwheel invocation.

dbogdanov added a commit to MTG/essentia that referenced this issue Sep 26, 2023
Cannot build the latest NumPy 1.26.0 from source without BLAS (works
with previous versions) on i686. Add custom before-test installation for NumPy:
numpy/numpy#24703
dbogdanov added a commit to MTG/essentia that referenced this issue Sep 26, 2023
NumPy does not provide wheels for i686 and they are built from source
with pip for Essentia wheels builds. However, since Numpy 1.26.0, the build
fails due to missing BLAS: numpy/numpy#24703

The simplest solution, similar to other projects, is to disable i686 builds
entirely, given that the i686 is getting too outdated and uncommon.
dbogdanov added a commit to MTG/essentia that referenced this issue Sep 26, 2023
NumPy does not provide wheels for i686 and they are built from source with pip
for Essentia wheels builds. However, since Numpy 1.26.0, the build fails due to
missing BLAS: numpy/numpy#24703

The simplest solution, similar to other projects, is to disable i686 builds
entirely, given that the i686 is getting too outdated and uncommon.
agriyakhetarpal added a commit to agriyakhetarpal/PyBaMM that referenced this issue Sep 28, 2023
mgao6767 added a commit to mgao6767/frds that referenced this issue Oct 1, 2023
@ReenigneArcher
Copy link

@rgommers replacing cmake with pkg-config resolved it. Thank you!

@mattip
Copy link
Member

mattip commented Oct 5, 2023

It would be nice to debug why the CMake files supplied with openblas are not sufficient. Is there a command-line interface to the cmake module discovery mechanism?

@rfrenchseti
Copy link

Just adding to the above comments, I just ran into the same problem trying to update a package I maintain (that depends on numpy) to work with Python 3.12. I tried everything I could think of, including adding the cibuildwheel pre-install of numpy with the allow-noblas=true option and I just couldn't get it to work. Disabling the build of *i686 eventually solved the problem, but is obviously not ideal.

@ReenigneArcher
Copy link

@rfrenchseti try adding these packages before installing numpy.

        pkg-config \
        libopenblas-dev \

Names may be different depending on which distro.

@kif
Copy link
Contributor

kif commented Oct 26, 2023

Just for info, we face the same issue when doing CI on an architecture where no wheels are provided (PPC64le).
Numpy should just build by default, even with the largest warning about bad performances, but it should not fail building because so many projects have numpy as a dependency.

rgommers added a commit to rgommers/numpy that referenced this issue Nov 3, 2023
Having it set to false caused more disruption and complaints than
the silent performance regressions for `true` ever did.
So now that the dust has settled a bit on the transition to Meson,
go back to the more permissive default.

The warning that is emitted when BLAS and/or LAPACK are not found
is already much more visible than it was with distutils, so this
new situation is still an improvement over where we were until
1.25.x.

Closes numpygh-24703.
@rgommers
Copy link
Member

rgommers commented Nov 3, 2023

Thanks for the input everyone. I just opened gh-25063 to revert the default to allow-noblas=true. That should land in 1.26.2 and 2.0.

@rgommers rgommers added this to the 1.26.2 release milestone Nov 4, 2023
kennethjiang added a commit to TheSpaghettiDetective/obico-server that referenced this issue Nov 6, 2023
charris pushed a commit to charris/numpy that referenced this issue Nov 11, 2023
Having it set to false caused more disruption and complaints than
the silent performance regressions for `true` ever did.
So now that the dust has settled a bit on the transition to Meson,
go back to the more permissive default.

The warning that is emitted when BLAS and/or LAPACK are not found
is already much more visible than it was with distutils, so this
new situation is still an improvement over where we were until
1.25.x.

Closes numpygh-24703.
charris pushed a commit to charris/numpy that referenced this issue Nov 11, 2023
Having it set to false caused more disruption and complaints than
the silent performance regressions for `true` ever did.
So now that the dust has settled a bit on the transition to Meson,
go back to the more permissive default.

The warning that is emitted when BLAS and/or LAPACK are not found
is already much more visible than it was with distutils, so this
new situation is still an improvement over where we were until
1.25.x.

Closes numpygh-24703.
nsoranzo added a commit to nsoranzo/oldest-supported-numpy that referenced this issue Dec 12, 2023
numpy 1.26 before 1.26.2 enforced the presence of a blas library when building from source, e.g. on i686 ( numpy/numpy#24703 )
rgommers pushed a commit to scipy/oldest-supported-numpy that referenced this issue Dec 12, 2023
numpy 1.26 before 1.26.2 enforced the presence of a blas library when building from source, e.g. on i686 ( numpy/numpy#24703 )
@TimotheusBachinger
Copy link

TimotheusBachinger commented Dec 20, 2023

For anyone who runs into this - based on:

This is the syntax for pip:

python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true" 

For everybody running into that (like myself): This works only from numpy version 1.26.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32 - Installation Problems installing or compiling NumPy 33 - Question Question about NumPy usage or development
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants