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
BLD: undefined symbol: cblas_sgemm when building with meson with pip install #23909
Comments
Hit the same in Gentoo and was trying to minimise it but came across this! Thank you! |
Meson builds for NumPy are still a WIP: the OpenBLAS interface detection and SIMD support is still in flux. Here are a few hints: You should see, very early in the meson build, something like
Note the last two lines which show it is finding OpenBLAS via pkgconfig. If you see that, the build should link to OpenBLAS. Additionally, there is a way to configure NumPy to use a build of OpenBLAS with 64-bit interfaces instead of 32-bit ones. This is called ILP64, and is currently expressed in a few environment variables and C macros (our convention is to add a |
I guess this is related to https://github.com/numpy/numpy/pull/23838/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R150 then, which at least I was applying. Thanks for the hint, I'll look into it more now. EDIT: I found what I was doing wrong -- I was passing |
If you really want the 64-bit interfaces like in our wheels, you can get OpenBLAS from https://anaconda.org/multibuild-wheels-staging/openblas-libs/files, expand the tarball, and point PKG_CONFIG_PATH to the pkgconfig directory. Make sure it works by checking that |
I am now using the branch in gh-23838. My meson build does show these two lines:
It seems my system openblas doesn't indicate its version in the pkg-config file. I am building with just |
How are you checking for OpenBLAS? Could you be picking up a static library? |
I have the pkg-config file
(the version is indeed left empty, although the system package manager says it's 0.3.23) And the dynamic libraries |
In
I see this
|
So... this means that I need to change the |
My goal was to guide you to how you can debug the build. Do you see those link arguments? You can work backwards from there trying to figure out where |
In my build meson actually finds the
(By the way in my system (Archlinux) libcblas is installed separately and is a standalone dynamic library Update: I realized that my system provides openblas as a drop-in replacement for netlib blas. So although I have openblas installed, maybe I actually need to build numpy to link to blas instead of openblas...? Strangely, after I change openblas to blas in
But Update 2: The content of |
It is hard to debug this. You need to stare at the different options until they start to make sense. If the |
So... it seems numpy does need to link to cblas. In my system, the symbol |
If this is something you think others will run into, it would be nice to summarize your changes and see how we can integrate them into the meson build. |
I made two changes:
@@ -12,8 +12,8 @@ project(
'b_ndebug=if-release',
'c_std=c99',
'cpp_std=c++17',
- 'blas=openblas',
- 'lapack=openblas',
+ 'blas=blas',
+ 'lapack=blas',
'pkgconfig.relocatable=true',
],
)
@@ -859,7 +859,7 @@ py.extension_module('_multiarray_umath',
'src/npymath',
'src/umath',
],
- dependencies: blas,
+ dependencies: [blas, cblas],
link_with: npymath_lib,
install: true,
subdir: 'numpy/core', |
Yes, the |
I believe we unconditionally require CBLAS wherever we use BLAS, if BLAS is present and we're not using our own C implementation for matmul & co. So we may fix it more robustly by adding something like: if have_blas
blas_dep = declare_dependency(
dependencies: [blas, cblas],
compile_args: '-DHAVE_CBLAS',
)
endif and then everywhere else use |
So Archlinux just released a new version of OpenBLAS that includes cblas symbols and LAPACK support... Seems the modifications are no longer necessary. However, if the user wants to use the package |
Ah, that is awesome, that solves a pain point - thanks for pointing that out @refparo! |
In a conda env: ``` Run-time dependency openblas found: YES 0.3.23 Checking if "CBLAS" with dependency openblas: links: YES ``` On Arch Linux before the just-updated 0.23.23-2 build that included CBLAS and LAPACK in the `openblas` package (see numpygh-23909): ``` $ python -m build --wheel ... Run-time dependency openblas found: YES Checking if "CBLAS" with dependency openblas: links: NO Run-time dependency cblas found: YES 3.11.0 ... $ ldd numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so linux-vdso.so.1 (0x00007fff59235000) libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f5cb4b08000) libcblas.so.3 => /usr/lib/libcblas.so.3 (0x00007f5cb62b3000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f5cb4a1b000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f5cb628e000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f5cb4831000) libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f5cb623d000) /usr/lib64/ld-linux-x86-64.so.2 (0x00007f5cb62f2000) ``` Closes numpygh-23909
In a conda env: ``` Run-time dependency openblas found: YES 0.3.23 Checking if "CBLAS" with dependency openblas: links: YES ``` On Arch Linux before the just-updated 0.23.23-2 build that included CBLAS and LAPACK in the `openblas` package (see numpygh-23909): ``` $ python -m build --wheel ... Run-time dependency openblas found: YES Checking if "CBLAS" with dependency openblas: links: NO Run-time dependency cblas found: YES 3.11.0 ... $ ldd numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so linux-vdso.so.1 (0x00007fff59235000) libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f5cb4b08000) libcblas.so.3 => /usr/lib/libcblas.so.3 (0x00007f5cb62b3000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f5cb4a1b000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f5cb628e000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f5cb4831000) libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f5cb623d000) /usr/lib64/ld-linux-x86-64.so.2 (0x00007f5cb62f2000) ``` Closes numpygh-23909
@refparo and @thesamesam this issue should be fixed by gh-23984. I tested on Arch Linux, not on Gentoo. There's more to do for the overall BLAS/LAPACK detection to make it |
In a conda env: ``` Run-time dependency openblas found: YES 0.3.23 Checking if "CBLAS" with dependency openblas: links: YES ``` On Arch Linux before the just-updated 0.23.23-2 build that included CBLAS and LAPACK in the `openblas` package (see gh-23909): ``` $ python -m build --wheel ... Run-time dependency openblas found: YES Checking if "CBLAS" with dependency openblas: links: NO Run-time dependency cblas found: YES 3.11.0 ... $ ldd numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so linux-vdso.so.1 (0x00007fff59235000) libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f5cb4b08000) libcblas.so.3 => /usr/lib/libcblas.so.3 (0x00007f5cb62b3000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f5cb4a1b000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f5cb628e000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f5cb4831000) libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f5cb623d000) /usr/lib64/ld-linux-x86-64.so.2 (0x00007f5cb62f2000) ``` Closes gh-23909
Thanks, I've got this on my queue to look at now. Will comment again with results. |
Steps to reproduce:
pip install -r requirements
build-backend = "mesonpy"
.pip install --no-build-isolation .
.The OS I use is Archlinux, and
openblas
andcblas
are installed. In case it is relevant,openblas.pc
is present in/usr/lib/pkgconfig/
.Error message:
Additional information:
ldd
shows that the compiled library is not linking against BLAS at all.The text was updated successfully, but these errors were encountered: