idiap / pkwrap

A pytorch wrapper for LF-MMI training and parallel training in Kaldi
Other
72 stars 12 forks source link

undefined symbol after building #13

Closed kingsword5566 closed 3 years ago

kingsword5566 commented 3 years ago

Hi I follow the instructions of installation but I encountered some errors in import pkwrap. The error message are: undefined symbol: _ZN5kaldi23SplitStringOnFirstSpaceERKSsPSsS2_

I check the step make but it shows normal. Finished processing dependencies for pkwrap==0.2.27.2

mrsrikanth commented 3 years ago

Hello,

Did you compile Kaldi with CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"?

This error is most likely due to a mismatch in the compilation flag.

Srikanth

kingsword5566 commented 3 years ago

Sorry my fault. But when I add -D_GLIBCXX_USE_CXX11_ABI=0 in kaldi.mk It cause many errors.

mrsrikanth commented 3 years ago

Without that the Kaldi library will be incompatible with Pytorch. I don't know if adding the option directly to kaldi.mk makes sense. Would that be different from doing the following?

export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
./configure --shared
make clean && make depend -j $NUM_JOBS
make -j $NUM_JOBS
kingsword5566 commented 3 years ago

It was success when I normal compile. But add the -D_GLIBCXX_USE_CXX11_ABI it would get some strange error My kaldi version is c81f517

mrsrikanth commented 3 years ago

The kaldi version seems way too old (from 2018). Would it be possible to update it?

kingsword5566 commented 3 years ago

I updated to newest version and export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" before make It still got some ld error

../hmm/libkaldi-hmm.so: undefined reference to `fst::FstHeader::Write(std::ostream&, std::string const&) const'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'fgmm-global-gselect-to-post' failed
kingsword5566 commented 3 years ago

The detail compile process is below:

  1. go to tools/
    ./extras/check_dependencies.sh
    make -j4
  2. go to src/
    export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
    ./configure --shared
    make -j clean depend; make -j4
pchampio commented 3 years ago

If this helps, here is my installation script.

#!/bin/bash

set -e

nj=$(nproc)

home=$PWD

conda_url=https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
venv_dir=$PWD/venv

mark=.done-venv
if [ ! -f $mark ]; then
  echo 'Making python virtual environment'
  name=$(basename $conda_url)
  if [ ! -f $name ]; then
    wget $conda_url || exit 1
  fi
  [ ! -f $name ] && echo "File $name does not exist" && exit 1
  [ -d $venv_dir ] && rm -r $venv_dir
  sh $name -b -p $venv_dir || exit 1
  . $venv_dir/bin/activate

  echo 'Installing conda dependencies'
  yes | conda install -c conda-forge sox
  yes | conda install -c conda-forge libflac
  touch $mark
fi
echo "if [ \$(which python) != $venv_dir/bin/python ]; then source $venv_dir/bin/activate; fi" > env.sh

source $venv_dir/bin/activate

export CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"

mark=.done-kaldi-tools
if [ ! -f $mark ]; then
  echo 'Building Kaldi tools'
  rm -rf kaldi
  git clone https://github.com/kaldi-asr/kaldi.git || true
  # git checkout d619890
  cd kaldi/tools
  extras/check_dependencies.sh || exit 1
  make -j $nj || exit 1
  cd $home
  touch $mark
fi

mark=.done-kaldi-src
if [ ! -f $mark ]; then
  echo 'Building Kaldi src'
  cd kaldi/src
  ./configure --shared --use-cuda=yes --mathlib=ATLAS || exit 1
  make clean || exit 1
  make depend -j $nj || exit 1
  make -j $nj || exit 1
  cd $home
  touch $mark
fi

mark=.done-pytorch
if [ ! -f $mark ]; then
#### MODIFY THIS TO YOUR VERSION OF PYTORCH/CUDA
  pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
  cd $home
  touch $mark
fi

export KALDI_ROOT=$home/kaldi
mark=.done-pkwrap
if [ ! -f $mark ]; then
  echo 'Building pkwrap src'
  rm -rf pkwrap
  git clone https://github.com/idiap/pkwrap.git
  cd pkwrap
  # git checkout ccf4094
  make
  pip install -e .
  cd $home
  touch $mark
fi
kingsword5566 commented 3 years ago

@pchampio Thanks a lot! Now I compiled my kaldi successfully But when I compile pkwrap, I encountered the error: /usr/include/cublas_api.h:72:10: fatal error: driver_types.h: No such file or directory

I checked my directory and found that driver_types.h is under the /usr/local/cuda/include not /usr/include

kingsword5566 commented 3 years ago

Solved by cp -r /usr/local/cuda/include/* /usr/include