KaldiDecoder (Source Compilation for person concerned)

These instructions are for KaldiDecoder version 2.5.0 or later.

Compilation Environment

  • OS
    • Ubuntu 16.04 Xenial (64bit)
    • Ubuntu 18.04 Bionic (64bit)
    • Ubuntu 20.04 Focal (64bit)
    • Ubuntu 22.04 Jammy (64bit)

Notes: KaldiDecoder uses the Kaldi libraries, so it can only be built in an environment supported by the Kaldi officially site (http://kaldi-asr.org/).

 

Installation instruction

Step.1 Get build tools and dependent libraries.

sudo apt update
sudo apt install git automake autoconf libtool cmake cmake-extras build-essential libopenblas-base libopenblas-dev gfortran liblapack-dev liblapacke-dev zlib1g-dev sox subversion

For Ubuntu 20.04 or later users, you will need to additionally install the python2.7 package.

sudo apt install python2.7

 

Step.2 Get the unofficial Kaldi source code.

cd ~/
mkdir YOUR_DIR
cd YOUR_DIR
# git clone https://******
# git checkout BRANCH
#           or
# tar -zxvf ******.tar.gz
cd kaldi
  • BRANCH : The name of the development branch you are targeting

 

Step.3 Build Kaldi’s external tool (and dependent library).

cd tools
extras/check_dependencies.sh
#### The following message is displayed but there is no problem. Because we use openblas.
# You should probably do:
#  sudo apt-get install libatlas3-base
make

 

Step.4 Build Kaldi with the set up to use openblas library.

For Ubuntu 16.04 users.

cd ../src
./configure --mathlib=OPENBLAS --openblas-root=/usr
make clean -j CORES
make depend -j CORES
make -j CORES
  • CORES : How many cores do you have
      e.g.) 4
      Note: About 2GB of memory is required for each core when compiling. Please set the number of cores considering free memory capacity.

 

For Ubuntu 18.04 or later users, the following workaround is required because the openblas library path was changed.

cd ../src
mkdir fakeroot
ln -s /usr/include/x86_64-linux-gnu/ fakeroot/include
ln -s /usr/lib/x86_64-linux-gnu/ fakeroot/lib
./configure --mathlib=OPENBLAS --openblas-root=fakeroot
make clean -j CORES
make depend -j CORES
make -j CORES
  • CORES : How many cores do you have
      e.g.) 4
      Note: About 2GB of memory is required for each core when compiling. Please set the number of cores considering free memory capacity.

 

Step5. Build KaldiDecoder.

cd ../kaldidecoder3
mkdir build
cd build
cmake .. -DOPENBLAS_ROOT_DIR:STRING=/usr -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE
make
sudo make install

 

Q&A

Q.1 Is there a way to enable CUDA?
A.1 If you are using 3.1.0-openblas or later, the answer is Yes, but do so at your own risk.

Steps 1 to 3 are the same. For installation of CUDA toolkit please refer to nVidia official installation instructions.

  • nVidia CUDA Toolkit
      https://developer.nvidia.com/cuda-downloads

 

Step.4 Build Kaldi with the set up to use openblas library. (with CUDA)

For Ubuntu 16.04 users.

cd ../src
./configure --mathlib=OPENBLAS --openblas-root=/usr --use-cuda --cudatk-dir=/usr/local/cuda
make clean -j CORES
make depend -j CORES
make -j CORES

Only the arguments of '--use-cuda' and '--cudatk-dir=PATH' have been added by the './configure' command.
 

For Ubuntu 18.04 or later users, the following workaround is required because the openblas library path was changed.

cd ../src
mkdir fakeroot
ln -s /usr/include/x86_64-linux-gnu/ fakeroot/include
ln -s /usr/lib/x86_64-linux-gnu/ fakeroot/lib
./configure --mathlib=OPENBLAS --openblas-root=fakeroot --use-cuda --cudatk-dir=/usr/local/cuda
make clean -j CORES
make depend -j CORES
make -j CORES

Only the arguments of '--use-cuda' and '--cudatk-dir=PATH' have been added by the './configure' command.
 

Step5. Build KaldiDecoder. (with CUDA)

cd ../kaldidecoder3
mkdir build
cd build
cmake .. -DOPENBLAS_ROOT_DIR:STRING=/usr -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE -DUSE_CUDA=ON
make
sudo make install

Only the arguments of '-DUSE_CUDA=ON' have been added by the 'cmake' command.
If you have multiple versions of CUDA installed and you want to set your PATH:

cmake .. -DOPENBLAS_ROOT_DIR:STRING=/usr -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE -DUSE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0

Make sure that the PATH specified here is the same as the PATH specified in Step 4.
 

Q.2 Build fails on CUDA11. Is there a workaround?
A.1 Use a combination of Kaldi 5.5.636 or later and KaldiDecoder 3.4.0 or later.

Back to Top