在MacOS 下跑 kaldi
brew install automake llvm cmake sox libtool subversion
基本安装
brew install pyenv
pyenv install -v 2.7.18
# Set the python version.
pyenv global 2.7.18
# Export PATH if necessary.
export PATH="$(pyenv root)/shims:${PATH}"
Add if necessary.:
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
还得是用 xcode 的 sdk, brew 很多都显示找不到对应的包, 用了 CPPFLAG也不行
==> /opt/homebrew/bin/pyenv install 2.7.18
Downloading openssl-1.1.1v.tar.gz...
-> https://www.openssl.org/source/openssl-1.1.1v.tar.gz
Installing openssl-1.1.1v...
Installed openssl-1.1.1v to /Users/zorch/.pyenv/versions/2.7.18
Downloading readline-8.0.tar.gz...
-> https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz
Installing readline-8.0...
Installed readline-8.0 to /Users/zorch/.pyenv/versions/2.7.18
Downloading Python-2.7.18.tar.xz...
-> https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
Installing Python-2.7.18...
patching file configure
patching file configure.ac
patching file setup.py
patching file 'Mac/Tools/pythonw.c'
patching file setup.py
patching file 'Doc/library/ctypes.rst'
patching file 'Lib/test/test_str.py'
patching file 'Lib/test/test_unicode.py'
patching file 'Modules/_ctypes/_ctypes.c'
patching file 'Modules/_ctypes/callproc.c'
patching file 'Modules/_ctypes/ctypes.h'
patching file 'Modules/_ctypes/callproc.c'
patching file setup.py
patching file 'Mac/Modules/qt/setup.py'
patching file setup.py
python-build: use zlib from xcode sdk
Installed Python-2.7.18 to /Users/zorch/.pyenv/versions/2.7.18
还需要加入环境变量
==> pyenv global 2.7.18
√ ~/code/c-cpp_proj/kaldi/tools
==> python2
Python 2.7.18 (default, Dec 16 2023, 14:23:06)
[GCC Apple LLVM 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
==> which python2
/Users/zorch/.pyenv/shims/python2
安装 openblas
gfortran 11 ARM-darwin (Apple M1) build failure · Issue #3222 · OpenMathLib/OpenBLAS;
改版本
==> vi extras/install_openblas.sh
OPENBLAS_VERSION=0.3.20
之前是 0.3.13
==> sw_vers -productVersion
14.1
√ ~/code/c-cpp_proj/kaldi/tools
==> MACOSX_DEPLOYMENT_TARGET=14.1 extras/install_openblas.sh
结果
OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)
OS ... Darwin
Architecture ... arm64
BINARY ... 64bit
C compiler ... CLANG (cmd & version : Apple clang version 15.0.0 (clang-1500.1.0.2.5))
Fortran compiler ... GFORTRAN (cmd & version : GNU Fortran (Homebrew GCC 13.2.0) 13.2.0)
-n Library Name ... libopenblas_armv8-r0.3.20.a
(Single-threading)
WARNING: If you plan to use the dynamic library libopenblas_armv8-r0.3.20.dylib, you must run:
"make PREFIX=/your_installation_path/ install".
(or set PREFIX in Makefile.rule and run make install.
If you want to move the .dylib to a new location later, make sure you change
the internal name of the dylib with:
install_name_tool -id /new/absolute/path/to/libopenblas_armv8-r0.3.20.dylib libopenblas_armv8-r0.3.20.dylib
To install the library, you can run "make PREFIX=/path/to/your/installation install".
/Applications/Xcode.app/Contents/Developer/usr/bin/make -j 11 -f Makefile.install install
Generating openblas_config.h in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/include
Generating f77blas.h in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/include
Generating cblas.h in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/include
Copying LAPACKE header files to /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/include
Copying the static library to /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/lib
Copying the shared library to /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/lib
Generating openblas.pc in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/lib/pkgconfig
Generating OpenBLASConfig.cmake in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/lib/cmake/openblas
Generating OpenBLASConfigVersion.cmake in /Users/zorch/code/c-cpp_proj/kaldi/tools/OpenBLAS/install/lib/cmake/openblas
Install OK!
OpenBLAS is installed successfully.
issue 永远滴神
检验
==> extras/check_dependencies.sh
extras/check_dependencies.sh: all OK.
正餐开始
# optional, exec if you have built the old version
# make -j clean depend
cd src/
./configure --use-cuda=no
make -j11
跑一个例子试试
cd egs/yesno/s5
==> make test -j10