py-kaldi-asr icon indicating copy to clipboard operation
py-kaldi-asr copied to clipboard

Not able to run the example on Ubuntu 16.04

Open ghost opened this issue 6 years ago • 6 comments

ImportError: libkaldi-decoder.so: cannot open shared object file: No such file or directory.

Can you share simple steps to do on ubuntu 16.04 && g++ 5.4.0 to run the basic demo?

ghost avatar Sep 25 '19 04:09 ghost

Just add LD_LIBRARY_PATH environment containing the path where this shared-object of kaldi installation is. For some reason, all the mechanisms of installation are really working badly, and no one is checking them. After that you'll probably have to add also the fst path which was changes to fst-1.6.7 And then maybe use LD_PRELOAD for the mkl libs of intel, which are another issue. Unfortunately nobody checks those installations.

RaniRaven avatar Sep 30 '19 15:09 RaniRaven

Same here on Ubuntu 18.04 . export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/kaldi/src/lib:/opt/kaldi/tools/openfst/lib did the trick. Now the python imports of KaldiNNet3OnlineModel and KaldiNNet3OnlineDecoder are running without errors. Next problem: mkl libs.

Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from kaldiasr.nnet3 import KaldiNNet3OnlineModel
>>> kaldi_model = KaldiNNet3OnlineModel('path/to/model_dir')
Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.

As @RaniRaven writes:

And then maybe use LD_PRELOAD for the mkl libs of intel, which are another issue.

Finding and adding libmkl_avx2.so results in:

$ export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_avx2.so
$ python3
python3: symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_avx2.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8

Ok, something is missing here. Let's add all mkl libs in that directory:

$ export LD_PRELOAD=$(ls /opt/intel/mkl/lib/intel64/*.so | tr '\n' ':')
$ python3
python3: symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_tbb_thread.so: undefined symbol: _ZN3tbb4task13note_affinityEt

What exactly should LD_PRELOAD look like?

KannebTo avatar Dec 08 '19 11:12 KannebTo

I had exactly the same problem. This worked for me:

$ export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_sequential.so

Source: https://www.bountysource.com/issues/81528572-intel-mkl-fatal-error-cannot-load-libmkl_def-so

hjpulakka avatar Dec 11 '19 10:12 hjpulakka

Thanks @hjpulakka. This is working on my system now.

KannebTo avatar Dec 11 '19 23:12 KannebTo

That LD_PRELOAD location didn't work for me. this did:

export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_def.so:/opt/intel/mkl/lib/intel64/libmkl_avx2.so:/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so:/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so:/opt/intel/lib/intel64_lin/libiomp5.so

CedHild avatar Mar 16 '20 20:03 CedHild

@sravani40 This depends on how you launch your python program. If you using the terminal (with bash) you can simply add these lines to your ~/.bashrc. Here you can read about other methods for persisting environment variables.

KannebTo avatar Feb 11 '21 10:02 KannebTo