Ubuntu16.04下安装Kaldi

Ubuntu16.04下安装Kaldi

  • CUDA的安装
    • CUDA安装注意的几点:
  • Kaldi环境配置
    • Kaldi的编译

CUDA的安装

在配置Kaldi环境之前,需要在Ubuntu里安装CUDA

CUDA的具体安装教程可参考这一篇博文。

CUDA安装注意的几点:

1.不同版本的CUDA安装对应着不同Linux内核,例如我安装的CUDA9.0对应着4.40版本的内核,而Ubuntu16.04系统的默认内核为4.15,所以需要对内核降级。具体对应表可参考CUDA安装的官方文档。

2.安装CUDA前需要禁用Ubuntu16系统默认的显卡驱动nouveau。

3.安装的时候需要按Ctrl+Alt+F1进入文本模式(命令行界面)完成安装。

其它的详细安装步骤可参考之前提供的博文。

Kaldi环境配置

首先在终端使用命令将Kaldi包下载至本地。

git clone https://github.com/kaldi-asr/kaldi.git kaldi-trunk --origin golden

若没有安装git,终端会给出安装git的提示,按照提示安装即可。

Kaldi的编译

Kaldi本地包下载后,可以在主目录里看到一个INSTALL文件,里面是告诉我们如何编译Kaldi。
内容如下:

This is the official Kaldi INSTALL. Look also at INSTALL.md for the git mirror installation.
[for native Windows install, see windows/INSTALL]

(1)
go to tools/  and follow INSTALL instructions there.

(2) 
go to src/ and follow INSTALL instructions there.

告诉我们先去tools文件夹中,按照里面的INSTALL文件的指导进行部署。
tools文件夹中的INSTALL文件内容如下:

To check the prerequisites for Kaldi, first run

  extras/check_dependencies.sh

and see if there are any system-level installations you need to do. Check the
output carefully. There are some things that will make your life a lot easier
if you fix them at this stage. If your system default C++ compiler is not
supported, you can do the check with another compiler by setting the CXX
environment variable, e.g.

  CXX=g++-4.8 extras/check_dependencies.sh

Then run

  make

which by default will install ATLAS headers, OpenFst, SCTK and sph2pipe.
OpenFst requires a relatively recent C++ compiler with C++11 support, e.g.
g++ >= 4.7, Apple clang >= 5.0 or LLVM clang >= 3.3. If your system default
compiler does not have adequate support for C++11, you can specify a C++11
compliant compiler as a command argument, e.g.

  make CXX=g++-4.8

If you have multiple CPUs and want to speed things up, you can do a parallel
build by supplying the "-j" option to make, e.g. to use 4 CPUs

  make -j 4

In extras/, there are also various scripts to install extra bits and pieces that
are used by individual example scripts.  If an example script needs you to run
one of those scripts, it will tell you what to do.

从中可知我们在此打开终端运行extras/check_dependencies.sh命令来检查环境的依赖,按照其提示将依赖配置好,配置好后再运行此命令会出现extras/check_dependencies.sh: all OK.,表示依赖已经配置好了。

再运行make命令进行安装,如果知道自己CPU核心数量,可以将其改成make -j x,其中x是核心数量,可以加快安装的速度。

出现All done OK表示这一步安装已经结束。

接下来进入src文件夹,INSTALL文件内容如下:


These instructions are valid for UNIX-like systems (these steps have
been run on various Linux distributions; Darwin; Cygwin).  For native Windows
compilation, see ../windows/INSTALL.

You must first have completed the installation steps in ../tools/INSTALL
(compiling OpenFst; getting ATLAS and CLAPACK headers).

The installation instructions are

  ./configure --shared
  make depend -j 8
  make -j 8

Note that we added the "-j 8" to run in parallel because "make" takes a long
time.  8 jobs might be too many for a laptop or small desktop machine with not
many cores.

For more information, see documentation at http://kaldi-asr.org/doc/
and click on "The build process (how Kaldi is compiled)".

从中我们知道只要依次输入

  ./configure --shared
  make depend -j 8
  make -j 8

这三行命令即可完成Kaldi的编译,其中8仍然是CPU核心的数量,因人而异。

其中./configure --shared是对依赖进行检查,按照其提示一步步安装即可。
当出现

SUCCESS

表示可以进行下一步操作。

完成接下来的两步操作,当出现

Done

表示Kaldi已经成功地在本地上完成了编译。
最后一步过程有点慢,我4核心的CPU编译花了大概半个小时。

为了保险起见,我们运行一个里面提供的实例看是否能够正常运行Kaldi。
进入目录

kaldi-trunk\egs\yesno\s5

在这里运行命令

./run.sh

如果出现结果如下

%WER 0.00 [ 0 / 232, 0 ins, 0 del, 0 sub ] exp/mono0a/decode_test_yesno/wer_10_0.0

那么恭喜你,完成了Kaldi的环境配置。

你可能感兴趣的:(Ubuntu16.04下安装Kaldi)