GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ENH: start to use OpenBLAS from a wheel by mattip · Pull Request #24749 · numpy/numpy

Conversation

@mattip

@mattip mattip commented Sep 19, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Follow on for MacPython/openblas-libs#87 which creates OpenBLAS wheels, available as scipy-openblas32 and scipy-openblas64. The wheel provides facilities for generating a openblas.pc file and for rewriting the _distributor_init.py file to first import the project, which will inject the dll/so into the process namespace and make the interfaces available. In order to use the wheel you must do one of these to build NumPy:

pip install scipy-openblas32 -r build_requirements.txt
spin build --with-scipy-openblas=32

or

pip install scipy-openblas64 -r build_requirements.txt
spin build --with-scipy-openblas=64

You can also use the non-spin pip install route for the 32-bit interfaces:

pip install scipy-openblas32 spin
spin config-openblas --with-scipy-openblas=32
export PKG_CONFIG_PATH=".openblas"
pip install .

I tried to modify most of the builds and wheel builds to use one of these workflows. One problem left to solve is specifying the runtime dependency for the wheels: which scipy-openblas should each platform use?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rgommers and seberg reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@github-actions github-actions Bot added the 01 - Enhancement label Sep 19, 2023
This was referenced Sep 20, 2023
BLD: start building with openblas wheel scipy/scipy#19269
Closed
Request access for scipy-openblas32 and scipy-openblas64 scientific-python/upload-nightly-action#42
Closed
scipy-openblas64 not installable on macos_arm64 MacPython/openblas-libs#113
Closed
BLD: add libquadmath to licences and other tweaks #24753
Merged
rgommers
rgommers reviewed Sep 21, 2023
View reviewed changes

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this moving forward. It looks like this PR will remove a lot of cruft.

One problem left to solve is specifying the runtime dependency for the wheels: which scipy-openblas should each platform use?

Probably best to make 1:1 replacements, and not change which of LP64/ILP64 is used in each of the CI jobs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/source/user/building.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/source/user/building.rst Outdated
There are two variants of the wheel, where possible we reccomend using the
one with 64-bit integer interfaces, which allow for larger arrays::

pip install scipy-openblas64 spin

@rgommers rgommers Sep 21, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of spin does not belong on this page, that should appear only on the pages aimed at contributors.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mattip mattip Sep 21, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Above the user is directed to use pip install -e . --no-build-isolation. How woul d you suggest they get the needed modifications before running that:

  • extract a properly configured openblas.pc from the scipy-openblas package
  • point PKG_CONFIG_PATH to it
  • modify _distributor_init.py

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mattip mattip Sep 21, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I could move the functionality I added to spin to do these things into to scipy-openblas, and then this would become

pip install scipy-openblas64
python -m scipy-openblas64 setup-repo="."
export PKG_CONFIG_PATH=${PWD}/.openblas   # bash
$env:PKG_CONFIG_PATH="$pwd/.openblas"  # powershell
pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_"

Is that preferable?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mattip mattip Sep 21, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea: push all this into numpy/meson.build, when configured with -Dblas=scipy-openblas32 or -Dblas=scipy-openblas64. It could take care of everything: creating the openblas.pc file, adding cflags, setting PKG_CONFIG_PATH, modifying _distributor_init.py.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Sep 21, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you suggest they get the needed modifications before running that:

They don't, that really isn't all that relevant here. BLAS/LAPACK remain external and generic build time dependencies. The wheel is for us to depend on, not for them to mess with directly.

Another idea: push all this into numpy/meson.build,

I'm not sure it's possible to set PKG_CONFIG_PATH from within Meson.

Either way, there may be an issue here in that the produced wheel will be cached by pip and will contain RPATH entries to a specific Python environment. That is going to break as soon as the user tries to install numpy into another environment.

I have to give it some more thought, but I think this is a little tricky, and perhaps a distraction from the main purpose of this PR right now. We want these wheels used by numpy and scipy wheels and in CI. I'd be inclined to scope this first PR to only that, and not user-facing changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Sep 22, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and we cannot add the scipy-openblasX dependency to the sdist without breaking builds from source on platforms for which we don't have openblas wheels.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Sep 22, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to fix this with a metapackage or a do-nothing scipy-openblasX sdist, but it needs some further hack like that. Or a proper solution, like adding a "pypi provider" concept for external dependencies to https://peps.python.org/pep-0725/.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andyfaff andyfaff Sep 22, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or could we combine both 32 bit and 64 into a single wheel, along with dummy do-nothing code?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mattip mattip Sep 22, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, now I get, sorry for being dense. If we add an ad-hoc dependency on, say, the manylinux2014 wheels for scipy-openblas64, and a dependency on, say, the 32-bit windows wheels for scipy-openblas32, and a dependency on, say, no openblas for macosx-arm64, then there is no way to reconcile all that for a single dependency for the sdist.

I guess another path would be to have a numpy[openblas64] wheel variant, but explaining pip install numpy[openblas64] seems like a nightmare.

Or could we combine both 32 bit and 64 into a single wheel, along with dummy do-nothing code?

Hmm. The problem is of course the wheel size: users would be downloading at least one useless large shared object. That is why I made two wheels.

PEP 725

I think the scipy-openblas wheels fall under the rejected category of external dependencies which are also packaged on PyPI

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rgommers rgommers Sep 22, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the scipy-openblas wheels fall under the rejected category of external dependencies which are also packaged on PyPI

Well I put it in that category because it seemed too niche - the PEP is still draft, so I can easily reverse that decision:)

the manylinux2014 wheels for scipy-openblas64, and a dependency on, say, the 32-bit windows wheels for scipy-openblas32, and a dependency on, say, no openblas for macosx-arm64, then there is no way to reconcile all that for a single dependency for the sdist.

I think we don't need any 32-bit wheel for numpy at least (scipy is a different story), so it's a little easier. We could have platform selectors perhaps, determining whether we want scipy-openblas64 or nothing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pyproject.toml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread azure-steps-windows.yml Outdated
elseif ( Test-Path env:NPY_USE_BLAS_ILP64 ) {
python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_"
python -m pip install scipy-openblas64
spin build --with-scipy-openblas=64

@rgommers rgommers Sep 21, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving pip invocations to spin should be a short-term thing, it's fine with me on Azure because that's so hard to debug. But can you please comment out the original line instead of removing it?

More importantly: I don't think this will work, because you removed the other CLI flags and they are needed. Can you instead do:

python -m pip install scipy-openblas64
export PKG_CONFIG_PATH=...  # whatever is the right path here
python -m pip install . -v -Csetup-args="--vsenv" -Csetup-args="-Duse-ilp64=true" -Csetup-args="-Dblas-symbol-suffix=64_"

?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mattip mattip Sep 21, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spin build will add the meson flags when invoked with --with-scipy-openblas=64 (in addition to creating the openblas.pc file, modifying _distributor_init.py, and adding the proper PKG_CONFIG_PATH).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread azure-pipelines.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

mattip
mattip commented Sep 21, 2023
View reviewed changes
Comment thread .spin/cmds.py
ctx.params["meson_args"] += (
"-Dblas-symbol-suffix=64_",
"-Duse-ilp64=true",
)

@mattip mattip Sep 21, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where spin build adds the meson arguments for 64-bit openblas builds

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mattip
mattip force-pushed the openblas-wheel branch from 4f60be0 to b68dd54 Compare September 26, 2023 11:21
@mattip

mattip commented Sep 26, 2023

Copy link
Copy Markdown
Member Author

I rebased off main and reduced the scope of the PR to CI build/test runs. We can decide how/if to use the scipy-openblas wheels as a runtime dependency in a future PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rgommers

rgommers commented Sep 26, 2023

Copy link
Copy Markdown
Member

All looks about right to me, now it's "only" a matter of making CI happy.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip
ENH: use OpenBLAS from a wheel
46439e5
@mattip
mattip force-pushed the openblas-wheel branch 4 times, most recently from 948c1f2 to 9d07277 Compare September 27, 2023 15:41
@mattip
CI fixes
ca639f0
@mattip
mattip force-pushed the openblas-wheel branch from 9d07277 to ca639f0 Compare September 27, 2023 15:57
@mattip

mattip commented Sep 27, 2023

Copy link
Copy Markdown
Member Author

It is too easy to run tests locally, which modify _distributor_init.py, and then mistakenly commit that changed file.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rgommers

rgommers commented Sep 27, 2023

Copy link
Copy Markdown
Member

Yeah it's never a good idea to modify files that are under version control. If you can't avoid a change, maybe change _distributor_init.py to the below?

# It's okay to replace this content:
try:
    # This `_local` file doesn't exist in VCS, so easier to modify for local development
    import ._distributor_init_local
except ImportError:
    pass
mattip reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip

mattip commented Sep 27, 2023 •
edited by rgommers
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

musllinux requires the ctypes.RTLD_GLOBAL flag, and should not link with libopenblas_python. Both of those changes need changes to the scipy-openblas wheels.

rgommers reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mattip
mattip commented Sep 27, 2023
View reviewed changes
Comment thread azure-pipelines.yml
python3 -m pip install -r test_requirements.txt && \
echo CFLAGS \$CFLAGS && \
python3 -m pip install -v . && \
spin openblas-config --with-scipy-openblas=32 && \

@mattip mattip Sep 27, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spin openblas-config --with-scipy-openblas=32 && \
spin openblas-config --with-scipy-openblas=32 && \
Suggested change
spin openblas-config --with-scipy-openblas=32 && \
spin config-openblas --with-scipy-openblas=32 && \

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mattip mattip mentioned this pull request Sep 28, 2023
BUG: meson detection of openblas builds an executable without using pkg-config --static --libs #24827
Closed
@mattip

mattip commented Sep 29, 2023

Copy link
Copy Markdown
Member Author

I will close this PR and start over, with the goal of accepting a blas=scipy-openblas option as suggested in #24827. The scipy-openblas.pc file now adds the needed cflags for ILP64 builds, so no extra command line flags are needed.

PKG_CONFIG_PATH=$PWD/.openblas python -m pip install . \
    --no-build-isolation -Csetup-args=-Dblas=scipy-openblas

An enhancement would be to search basedir/.openblas for the pkgconfig file.

rgommers reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip mattip closed this Sep 29, 2023
@rgommers rgommers mentioned this pull request Oct 4, 2023
BLD: use scipy-openblas wheel #24839
Merged
@mattip mattip mentioned this pull request Oct 4, 2023
ENH, BLD: use wheels to get BLAS implementations #24857
Open
@mattip mattip mentioned this pull request Oct 23, 2024
Shared library paths multi-build/multibuild#365
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rgommers rgommers rgommers left review comments
@andyfaff andyfaff andyfaff left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

01 - Enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mattip @rgommers @andyfaff
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.