最近在做语音识别项目的训练,发现需要安装pytorch版本的ctc,这个包需要编译,这里我来分享一下我的安装过程:

git clone https://github.com/SeanNaren/warp-ctc.git
cd warp-ctc
mkdir build; cd build
cmake ..

你可能会遇见下面的错误:

zsh: command not found: cmake

需要安装一下cmake:

brew install cmake

安装过程看网速了;然后:

make -j4

你可能会遇见下面的错误:

Scanning dependencies of target warpctc
[ 20%] Building CXX object CMakeFiles/warpctc.dir/src/ctc_entrypoint.cpp.o
clang: error: unsupported option '-fopenmp'
make[2]: *** [CMakeFiles/warpctc.dir/src/ctc_entrypoint.cpp.o] Error 1
make[1]: *** [CMakeFiles/warpctc.dir/all] Error 2
make: *** [all] Error 2

解决方法:

build/CMakeCache.txt

//compile warp-ctc with openmp.
// ON -> OFF
WITH_OMP:BOOL=OFF

然后运行:

cd ..
cd pytorch_binding
python setup.py install

你可能会遇见下面的问题:

warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on
      the command line to use the libc++ standard library instead
      [-Wstdlibcxx-not-found]
src/binding.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

在安装之前指定一下target和CXX参数就行了:

MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

参考文献

[1]. PyTorch bindings for Warp-CTC on MacOS. https://blog.csdn.net/xhzDeng/article/details/80511437

[2].src/binding.cpp:1:10: fatal error: 'iostream' file not found. https://github.com/SeanNaren/warp-ctc/issues/129

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐