Open grothesque opened 5 months ago
It's the same problem as the one described here https://github.com/rust-ndarray/ndarray?tab=readme-ov-file#how-to-enable-blas-integration in the Readme - at least I think it is. It says "your program must also link to blas_src by using it".
This is not great, but that's ndarray's design for blas right now to enable loose coupling between ndarray and blas versions. So we have some tangential docs. It happens that using ndarray_linalg is interchangeable with using blas_src.
Not sure how to improve this, probably add back a fixed requirement on blas src version and so on?
Thanks for the reply. I do not yet understand the problem completely, so I'm unable to suggest a fix at this time.
I spent some time trying to understand what's going on. Starting from the toy project described in the topmost post, I can obtain the same error message by replacing the following chunk in Cargo.toml
[dependencies]
ndarray = "0.15.6"
by
[dependencies.ndarray]
default-features = false
features = ["blas", "approx", "std"]
version = "0.15.2"
This latter chunk is taken directly from Cargo.toml
of ndarray-linalg
.
It is indeed the "blas" feature of ndarray
that triggers the problem.
Now looking, as you suggest, at the readme file of ndarray (I note in passing that the subsection title "How to enable blas integration" does not render correctly on github), it suggests to use
[dependencies]
ndarray = { version = "0.15.0", features = ["blas"] }
blas-src = { version = "0.8", features = ["openblas"] }
openblas-src = { version = "0.10", features = ["cblas", "system"] }
for system openblas.
However, this does not work on my box (neither as the only dependencies, or together with
ndarray-linalg = { version = "0.16.0", features = ["openblas-system"] }
So, disregarding ndarray-linalg
for a moment, is the suggestion in the readme file of ndarray
on how to use system openblas out of date, or am I missing something?
The following program builds and runs with
cargo run
. This is on current Debian stable with current Rust from rustup. The project was started from a freshcargo new
.src/main.rs
:Cargo.toml
:However, when the following dependency line is added to
Cargo.toml
cargo build
fails with the following linker error:This problem disappears when the following use declaration is added to the program
(However rustc warns about an "unused import"...)
I reckon that ndarray and ndarray-linalg have a tricky job here dealing with different sources of BLAS/LAPACK and a fallback implementation of matrix multiplication provided by the matrixmultiply crate. Still, it seems to me that the problem described above should be addressed in some way, at least by improving documentation.
It is very surprising when a program stops working after an unused dependency is added, and then can be made to build again by adding a needless use declaration.