Hello,
Since a while the use of Intel's MKL is free, and Kaldi compiles and runs well with it, and we all save the planet a little by using less energy; that is great!
However, we use the pykaldi wrapper in deployment, and so far I
haven't been able to get that going with MKL–-i've spent several days now, trying all kinds of configurations, debugging, and whatever, but I am not making any progress, I basically don't understand the dynamic linking process well enough (or not at all).
I am turning to this list because maybe there are people here that understand the intricacies of dynamic linking and python and perhaps even MKL.
A simple pykaldi test
```
LD_DEBUG=files python -m unittest tests/matrix/matrix-test.py 2>debug
```
fails with
```
Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.
```
I don't understand this because those exact files _can_ in fact be found, they're in ld.so.conf and in standard locations etc, but the `LD_DEBUG=files` may give some more information, near the end there are the lines
```
29453: file=/opt/intel/mkl/lib/intel64/libmkl_avx2.so [0]; dynamically loaded by /opt/intel/mkl/lib/intel64/libmkl_core.so [0]
29453: file=/opt/intel/mkl/lib/intel64/libmkl_avx2.so [0]; generating link map
29453: dynamic: 0x00007f8167420aa0 base: 0x00007f81638f4000 size: 0x0000000003b41a88
29453: entry: 0x00007f81639e7700 phdr: 0x00007f81638f4040 phnum: 7
29453: /opt/intel/mkl/lib/intel64/libmkl_avx2.so: error: symbol lookup error: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8 (fatal)
29453: file=/opt/intel/mkl/lib/intel64/libmkl_avx2.so [0]; destroying link map
```
The symbol `mkl_sparse_optimize_bsr_trsm_i8` is defined in the threading libraries like `libmkl_intel_thread.so`, which is used in compiling kaldi and later linking with pykaldi, in the `
kaldi.mk` var `LD_LIBS`, which evaluated in our case to
```
/home/david/src/pykaldi/tools/kaldi/tools/openfst/lib/libfst.so -L/opt/intel/mkl/lib/intel64 -Wl,-rpath=/opt/intel/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -L/opt/intel/compilers_and_libraries_2019.2.187/linux/compiler/lib/intel64_lin -Wl,-rpath=/opt/intel/compilers_and_libraries_2019.2.187/linux/compiler/lib/intel64_lin -liomp5 -ldl -lpthread -lm -lm -lpthread -ldl
```
I've tried all kinds of LD_PRELOAD and LD_LBRARY_PATH settings to help the dynamic linker, but then I end up in a endless chain of more undefined symbols. Just more proof that I don't understand linking.
Would anyone know how to proceed?
Thanks,
–-david