Issue with cargo dependency import

I have a patched version of a library. I am trying to use that library in an another application, however, imports are not correctly resolved.

[package]
name = "ndarray-mkl-issue"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ndarray = { version = "0.14" }
ndarray-linalg = { git = "https://github.com/trickster/ndarray-linalg", rev = "df3c062dc3a9415838973a511261758fd1ac6add", features = [
    "intel-mkl-system",
] }

With main.rs as:

use ndarray::*;
use ndarray_linalg::*;

fn main() {
    let a: Array2<f64> = array![
        [-1.01, 0.86, -4.60, 3.31, -4.81],
        [3.98, 0.53, -7.04, 5.29, 3.55],
        [3.30, 8.26, -3.89, 8.20, -1.51],
        [4.43, 4.96, -7.66, -7.33, 6.18],
        [7.31, -6.43, -6.16, 2.47, 5.58],
    ];
    let (eigs, vecs) = a.eig().unwrap();
}

I get this error, even though Eig is already exported by the dependency. The patched dependency passes all tests.

error[E0599]: no method named `eig` found for struct `ArrayBase` in the current scope
  --> src/main.rs:12:26
   |
12 |     let (eigs, vecs) = a.eig().unwrap();
   |                          ^^^ method not found in `ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>`

warning: unused import: `ndarray_linalg`
 --> src/main.rs:2:5
  |
2 | use ndarray_linalg::*;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `ndarray-mkl-issue` (bin "ndarray-mkl-issue") generated 1 warning
error: could not compile `ndarray-mkl-issue` due to previous error; 1 warning emitted

I understand the reproducibility is an issue here. We need to download intel-mkl for it to work. On a linux intel machine.

wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18483/l_onemkl_p_2022.0.2.136_offline.sh
sudo ./l_onemkl_p_2022.0.2.136_offline.sh -a -s --eula accept
source /opt/intel/oneapi/setvars.sh intel64

The above script with download the latest mkl, and set the env paths and variables.

Example repo - https://github.com/trickster/rs-mkl-issue/tree/fix

You need to use a [patch.crates-io] section if you want to override a dependency. You can read more here.

I am not overriding any dependency tho. I am just using a GitHub repo as a dependency.

The version of ndarray-linalg you are using depends on ndarray 0.15:

You are using ndarray 0.14.

3 Likes