Thursday, April 9, 2015

Installation

http://kaldi.sourceforge.net/install.html

$svn co https://svn.code.sf.net/p/kaldi/code/trunk kaldi-trunk

I am using ubuntu 14.04 64bit, gcc-4.7.

contact kaldi-developers@lists.sourceforge.net for questions.

sudo apt-get install gcc-4.7 g++-4.7 -y
To configure the gcc version, please check this link.

Install external libraries (inside toos/ folder)

ATLAS
turn off cpu throttling,
$/usr/bin/cpufreq-selector -g performance

I came across lots of errors after running the script install_atlas.sh under kaldi-trunk/tools/. 

You can install the atlas or openblas in ubuntu repo.
$sudo apt-get install libatlas3gf-base libatlas-dev -y
$sudo apt-get install libopenblas-dev -y

if 'libopenblas-dev' has no installation candidate, try the following
$sudo apt-get install libblas-dev

$sudo apt-get install libtool


Here are some quotes.
1) You don't have to build the ATLAS library, as Dan said, it is sufficient to install whatever package your system distribution provides. Atlas is sometimes quite hard to build because it tries to optimize everything for the machine on which it's being compiled. It also means that when you have
some specific machine configuration, the automatic build fails.
2) Kaldi supports OpenBLAS and/or Intel MKL already. You just have to install either one of those and call the configure script with the correct parameters. Configure --help lists these parameters.

run the script under ~/kaldi-trunk/tools/install_portaudio.sh
p.s. no sudo is needed, no errors
you will have the following msg:
Libraries have been installed in:
   /home/leiming/kaldi-trunk/tools/portaudio/install/lib
...
On some systems (e.g. Linux) you should run 'ldconfig' now to make the shared object available.  You may also need to modify your LD_LIBRARY_PATH environment variable to include the directory /home/leiming/kaldi-trunk/tools/portaudio/install/lib

add the lib in the ~/.bashrc, and source ~/.bashrc

download atlas, and unzip the package
wget -T 10 -t 3 http://sourceforge.net/projects/math-atlas/files/Stable/3.10.0/atlas3.10.0.tar.bz2 
tar -xvjf atlas3.10.0.tar.bz2

remain inside the tools folder, according to kaldi-trunk/tools/INSTALL, you can directly type make to install the tools.

My pc is intel i7, I will use 8 threads to make.
$make -j 8
Since no errors showed up, we are good. 

By default, Kaldi builds against OpenFst-1.3.4. If you want to build against
OpenFst-1.4, edit the Makefile in this folder. Note that this change requires
a relatively new compiler with C++11 support, e.g. gcc >= 4.6, clang >= 3.0.


install openfst-1.4
download openfst 1.4.1,  
$wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.4.1.tar.gz 
$tar -xvzf openfst-1.4.1.tar.gz
now cd to /kaldi-trunk/tools/openfst-1.4.1/src/include/fst
patch -p0 -N <../../../../extras/openfst-1.4.1.patch
rm openfst 2>/dev/null
ln -s openfst-1.4.1 openfst


cd openfst-1.4.1/
./configure --prefix=`pwd` --enable-static --disable-shared
make

make install


Here is some suggestion!
----------------------------------------------------------------------
Libraries have been installed in:
   /home/leiming/kaldi-trunk/tools/openfst-1.3.4/lib/fst

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

In my case, I edited the ~/.bashrc file and added the following line.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/leiming/kaldi-trunk/tools/openfst-1.3.4/lib/fst

Then, $source ~/.bashrc

Build the source file (in src/ folder)

go to /kaldi-trunk/src,
$./configure

After configure, you will have the following msg.
Configuring ...
Checking OpenFST library in /home/leiming/kaldi-trunk/tools/openfst ...
Checking OpenFst library was patched.
Doing OS specific configurations ...
On Linux: Checking for linear algebra header files ...
Using ATLAS as the linear algebra library.
Successfully configured for Debian/Ubuntu Linux [dynamic libraries] with ATLASLIBS =/usr/lib/libatlas.so.3  /usr/lib/libf77blas.so.3 /usr/lib/libcblas.so.3  /usr/lib/liblapack_atlas.so.3
Using CUDA toolkit /usr/local/cuda (nvcc compiler and runtime libraries)
Static=[false] Speex library not found: You can still build Kaldi without Speex.

speex library is used for audio compression when doing online decoding.


if you see "cuda will not be used!" msg, either you don't have cuda installed or the path is wrong.
In my case, i have several versions of cuda. I make a soft link to solve this issue(/usr/local).
$sudo ln -s cuda-7.0 cuda

$make depend -j 8
$make -j 8

automatically determine the cores of cpu when using make
make -j$(NUM_PROCESSORS)


For the new CUDA driver >= 6.5
nvcc fatal   : Unsupported gpu architecture 'compute_13'
make[1]: *** [cu-kernels.o] Error 1

go to /src/cudamatrix/, find the Makefile
  CUDA_ARCH=-gencode arch=compute_13,code=sm_13 \

remove ”-gencode arch=compute_13,code=sm_13”

then,  make -j 8

2 comments:

  1. Can you post about how neural networks are connected with speech recognition in Kaldi?. It seems difficult in connecting them. Thanks

    ReplyDelete
  2. how we use kaldi to recognize my voice in kaldi m new here i have no idea how to use. m already install kaldi.

    ReplyDelete