Deepspeech: Installing on arm64 | undefined symbol: DS_FreeMetadata

Created on 28 Jan 2020  路  12Comments  路  Source: mozilla/DeepSpeech

I'm unable to run the examples

OS: PureOS (Debian 10)
Platform: Librem5 (Arm64)
Python: 3.7.3
gcc: (Debian 8.3.0-6) 8.3.0

Step to duplicate:

#as root
apt-get install build-essential git unzip python3-numpy swig python3-setuptools python3-dev

#setup tensorflow-lite
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./tensorflow/lite/tools/make/download_dependencies.sh
./tensorflow/lite/tools/make/build_aarch64_lib.sh
#ouput is: ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a
cp ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a /usr/lib/aarch64-linux-gnu/

#setup DeepSpeech
cd ..
git clone https://github.com/mozilla/DeepSpeech.git
pip3 install setuptools
cd ./DeepSpeech/native_client/python/
python3 ./setup.py install

cd ../../../
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz
tar xvf deepspeech-0.6.0-models.tar.gz

#examples ONLY
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/audio-0.6.0.tar.gz
tar xvf audio-0.6.0.tar.gz
deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio audio/2830-3980-0043.wav

This gives the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/_impl.cpython-37m-aarch64-linux-gnu.so: undefined symbol: DS_FreeMetadata

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/deepspeech", line 11, in <module>
    load_entry_point('deepspeech==0.6.1', 'console_scripts', 'deepspeech')()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2853, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2444, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2450, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/__init__.py", line 23, in <module>
    from deepspeech.impl import PrintVersions as printVersions
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 17, in <module>
    _impl = swig_import_helper()
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 16, in swig_import_helper
    return importlib.import_module('_impl')
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_impl'

TensorFlow version:

root@pureos:/home/purism/voice_cmd/tensorflow# cat .git/refs/heads/master
2c46d0054750b679f6aaae4532ae0cf5fd286fc0
root@pureos:/home/purism/voice_cmd/tensorflow# git describe --tags
v1.12.1-23419-g2c46d00547

All 12 comments

I'm unable to run the examples

OS: PureOS (Debian 10)
Platform: Librem5 (Arm64)
Python: 3.7.3
gcc: (Debian 8.3.0-6) 8.3.0

Step to duplicate:

#as root
apt-get install build-essential git unzip python3-numpy swig python3-setuptools python3-dev

#setup tensorflow-lite
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./tensorflow/lite/tools/make/download_dependencies.sh
./tensorflow/lite/tools/make/build_aarch64_lib.sh
#ouput is: ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a
cp ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a /usr/lib/aarch64-linux-gnu/

#setup DeepSpeech
cd ..
git clone https://github.com/mozilla/DeepSpeech.git
pip3 install setuptools
cd ./DeepSpeech/native_client/python/
python3 ./setup.py install

cd ../../../
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz
tar xvf deepspeech-0.6.0-models.tar.gz

#examples ONLY
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/audio-0.6.0.tar.gz
tar xvf audio-0.6.0.tar.gz
deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio audio/2830-3980-0043.wav

This gives the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/_impl.cpython-37m-aarch64-linux-gnu.so: undefined symbol: DS_FreeMetadata

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/deepspeech", line 11, in <module>
    load_entry_point('deepspeech==0.6.1', 'console_scripts', 'deepspeech')()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2853, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2444, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2450, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/__init__.py", line 23, in <module>
    from deepspeech.impl import PrintVersions as printVersions
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 17, in <module>
    _impl = swig_import_helper()
  File "/usr/local/lib/python3.7/dist-packages/deepspeech-0.6.1-py3.7-linux-aarch64.egg/deepspeech/impl.py", line 16, in swig_import_helper
    return importlib.import_module('_impl')
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_impl'

TensorFlow version:

root@pureos:/home/purism/voice_cmd/tensorflow# cat .git/refs/heads/master
2c46d0054750b679f6aaae4532ae0cf5fd286fc0
root@pureos:/home/purism/voice_cmd/tensorflow# git describe --tags
v1.12.1-23419-g2c46d00547

You are not following the docs to rebuild. This can't work.

Also, we have pre-built packages for ARM64, have you tried them?

setup tensorflow-lite

git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./tensorflow/lite/tools/make/download_dependencies.sh
./tensorflow/lite/tools/make/build_aarch64_lib.sh

ouput is: ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a

cp ./tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a /usr/lib/aarch64-linux-gnu/

setup DeepSpeech

cd ..
git clone https://github.com/mozilla/DeepSpeech.git
pip3 install setuptools
cd ./DeepSpeech/native_client/python/
python3 ./setup.py install

Nowhere in our docs you will find those instructions: https://github.com/mozilla/DeepSpeech/blob/v0.6.1/native_client/README.rst

I somehow overlooked that doc, sorry!
It looks like it's an involved process to compile. :)
Where can I find the pre-build packages for ARM64?

I somehow overlooked that doc, sorry!
It looks like it's an involved process to compile. :)
Where can I find the pre-build packages for ARM64?

Well, it's not more complicated than what you did. You can find everything on github releases.

We can close this.
Quick question, is the TensorFlow version linked to the compiled version? Or did I just install the wrong version. :laughing:
I'm hoping to use tensorflowlite. The run time is... slow. 1 second takes about 11 to read.

solution. I was able to install with:

#try2:
sudo apt-get install alsa-utils #(Only for recording) 
mkdir ~/DeepSpech
cd ~/DeepSpech
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.6.1/native_client.arm64.cpu.linux.tar.xz
tar xvf ./native_client.arm64.cpu.linux.tar.xz
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.0/deepspeech-0.6.0-models.tar.gz
tar xvf deepspeech-0.6.0-models.tar.gz

Test commands:

#use it
arecord -vv -fdat to_txt.wav
./deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio ./to_txt.wav

Output:

purism@pureos:~/DeepSpech$ time ./deepspeech --model deepspeech-0.6.0-models/output_graph.pbmm --lm deepspeech-0.6.0-models/lm.binary --trie deepspeech-0.6.0-models/trie --audio ./to_txt.wav
TensorFlow: v1.14.0-21-ge77504a
DeepSpeech: v0.6.1-0-g3df20fe
wav: Premature EOF on .wav input file
this is a test eolipile boys to text feature

real    1m9.250s
user    1m14.323s
sys 0m0.273s
purism@pureos:~/DeepSpech$ time play ./to_txt.wav 
...
real    0m6.066s
user    0m0.171s
sys 0m0.082s

@lissyx Thanks for your time!

Quick question, is the TensorFlow version linked to the compiled version? Or did I just install the wrong version. laughing

libdeepspeech.so statically links against tensorflow, so you don't have to worry.

I'm hoping to use tensorflowlite. The run time is... slow. 1 second takes about 11 to read.

You should be able with current 0.7.0-alpha.0 binaries: we switched ARM64 to default to TFLite runtime after 0.6.1, but this alpha is still graph-compatible with 0.6.1: https://github.com/mozilla/DeepSpeech/releases/download/v0.7.0-alpha.0/native_client.arm64.cpu.linux.tar.xz

Please use 0.6.1 tflite model, not 0.6.0, since it is bugged.

Also, please note we only tested those on some ARM64 boards, but the SoC of the purism device is different. Maybe it's time I unbox my dev one :)

@lissyx

#try3:
sudo apt-get install alsa-utils #(Only for recording) 
mkdir ~/DeepSpech
cd ~/DeepSpech
wget https://github.com/mozilla/DeepSpeech/releases/download/v0.7.0-alpha.0/native_client.arm64.cpu.linux.tar.xz
tar xvf ./native_client.arm64.cpu.linux.tar.xz
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.6.1/deepspeech-0.6.1-models.tar.gz
tar xvf deepspeech-0.6.1-models.tar.gz

#use it
arecord -vv -fdat to_txt.wav
/deepspeech --model deepspeech-0.6.1-models/output_graph.tflite --lm deepspeech-0.6.1-models/lm.binary --trie deepspeech-0.6.1-models/trie --audio ./to_txt.wav

Output:

purism@pureos:~/DeepSpech$ time ./deepspeech --model deepspeech-0.6.1-models/output_graph.tflite --lm deepspeech-0.6.1-models/lm.binary --trie deepspeech-0.6.1-models/trie --audio ./to_txt.wav
TensorFlow: v1.15.0-24-gceb46aa
DeepSpeech: v0.7.0-alpha.0-0-g6af68ef
wav: Premature EOF on .wav input file
recording something about stuff and what not

real    0m12.538s
user    0m12.025s
sys 0m0.241s

I see the TensorFlow version is newer, but is it the lite version?

I see the TensorFlow version is newer, but is it the lite version?

Since you pass it the .tflite file, and it runs, yes.

Again, speed is highly dependant on the CPU. We have no feedback on that kind of CPU, so it's not surprising. Still, you went from 1 min 10 secs to only 13 secs, so there's improvement, and that confirms it's TFLite running as well. There's not much we can do.

That is massive improvement!
Keep up the good work, and thanks again for your time!
Let's see if I can build a small app around this. :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MuruganR96 picture MuruganR96  路  28Comments

MaxPowerWasTaken picture MaxPowerWasTaken  路  40Comments

lissyx picture lissyx  路  33Comments

verloka picture verloka  路  23Comments

breandan picture breandan  路  41Comments