Collecting deepspeech Downloading deepspeech-0.9.3-cp38-cp38-manylinux1_x86_64.whl (9.2 MB) |████████████████████████████████| 9.2 MB 416 kB/s Collecting numpy>=1.17.3 Downloading numpy-1.21.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB) |████████████████████████████████| 15.7 MB 24.2 MB/s Installing collected packages: numpy, deepspeech Successfully installed deepspeech-0.9.3 numpy-1.21.3 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Loading model from file deepspeech-0.9.3-models.pbmm TensorFlow: v2.3.0-6-g23ad988 DeepSpeech: v0.9.3-0-gf2e9c85 2021-10-28 07:40:01.471050: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Loaded model in 0.024s. Loading scorer from files deepspeech-0.9.3-models.scorer Loaded scorer in 0.00022s. Running inference. experience proves this Inference took 1.575s for 1.975s audio file.
没有问题,正确输出转文字结果。但是我们想要 GPU 加速。
1 2 3 4 5 6 7 8 9
pip3 install deepspeech-gpu # 下面是输出 Collecting deepspeech-gpu Downloading deepspeech_gpu-0.9.3-cp38-cp38-manylinux1_x86_64.whl (22.3 MB) |████████████████████████████████| 22.3 MB 698 kB/s Requirement already satisfied: numpy>=1.17.3 in /root/miniconda3/envs/deepspeech/lib/python3.8/site-packages (from deepspeech-gpu) (1.21.3) Installing collected packages: deepspeech-gpu Successfully installed deepspeech-gpu-0.9.3 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
2021-10-28 07:53:06.561665: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory 2021-10-28 07:53:06.561703: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Loading model from file deepspeech-0.9.3-models.pbmm TensorFlow: v2.3.0-6-g23ad988 DeepSpeech: v0.9.3-0-gf2e9c85 2021-10-28 07:53:06.786411: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-10-28 07:53:06.792126: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1 # 省略一些关于显卡的信息 2021-10-28 07:53:07.255877: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory 2021-10-28 07:53:07.256068: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory 2021-10-28 07:53:07.257113: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10 2021-10-28 07:53:07.257399: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10 2021-10-28 07:53:07.257546: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory 2021-10-28 07:53:07.257690: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcusparse.so.10'; dlerror: libcusparse.so.10: cannot open shared object file: No such file or directory 2021-10-28 07:53:07.257829: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory 2021-10-28 07:53:07.257847: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... # 省略一些关于显卡的信息 Loaded model in 0.492s. Loading scorer from files deepspeech-0.9.3-models.scorer Loaded scorer in 0.000226s. Running inference. experience proves this Inference took 1.785s for 1.975s audio file.
嗯……总之可以看到就是这也缺那也缺,安装一下 CUDA 10.1 看看,上面很多库都是 CUDA 10.1 的。
1
conda install cudatoolkit=10.1 -c nvidia
大约300多MB,安装完以后在测试。
1 2 3 4 5 6 7 8 9 10
# 只截取了关键输出 2021-10-28 07:58:37.492337: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 2021-10-28 07:58:37.494255: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 2021-10-28 07:58:37.496059: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10 2021-10-28 07:58:37.496379: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10 2021-10-28 07:58:37.498280: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10 2021-10-28 07:58:37.499158: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10 2021-10-28 07:58:37.499378: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory 2021-10-28 07:58:37.499395: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices...
可以看到大部分的库成功引入了,但是缺少 ‘libcudnn.so.7’ ……搜索了一下,这是一个 CUDA 9.0 的库文件……此刻心中万马奔腾……
2021-10-28 08:39:04.099199: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 2021-10-28 08:39:04.102018: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 2021-10-28 08:39:04.103797: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10 2021-10-28 08:39:04.104111: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10 2021-10-28 08:39:04.106148: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10 2021-10-28 08:39:04.107205: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10 2021-10-28 08:39:04.107373: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7 2021-10-28 08:39:04.111394: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0, 1, 2
2021-10-28 08:41:49.454505: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 2021-10-28 08:41:49.456171: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 2021-10-28 08:41:49.457685: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10 2021-10-28 08:41:49.457960: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10 2021-10-28 08:41:49.459548: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10 2021-10-28 08:41:49.460527: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10 [1] 51805 bus error (core dumped) deepspeech --model deepspeech-0.9.3-models.pbmm --scorer --audio
真的不想搞了,deepspeech 什么鬼?
搜了半天还是没搜到解决办法,最近事情也蛮多暂时在这挖个坑吧……
山穷水尽疑无路,柳暗花明又一村。
网上能搜到的资料基本都救不了,甚至一些资料当时 DeepSpeech 匹配的 CUDA 库还是 10.0 ,10.1 都用不了。
❯ deepspeech --model deepspeech-0.9.3-models.pbmm --scorer deepspeech-0.9.3-models.scorer --audio audio/2830-3980-0043.wav 2021-10-28 10:05:39.482388: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 Loading model from file deepspeech-0.9.3-models.pbmm TensorFlow: v2.3.0-6-g23ad988 DeepSpeech: v0.9.3-0-gf2e9c85 2021-10-28 10:05:39.654008: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-10-28 10:05:39.658194: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1 2021-10-28 10:05:40.081253: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: # 省略一些显卡信息 2021-10-28 10:05:40.082526: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1 2021-10-28 10:05:40.084675: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 2021-10-28 10:05:40.086519: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10 2021-10-28 10:05:40.086845: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10 2021-10-28 10:05:40.088980: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10 2021-10-28 10:05:40.089999: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10 2021-10-28 10:05:40.090156: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7 2021-10-28 10:05:40.093871: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0, 1, 2 2021-10-28 10:05:41.060113: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-10-28 10:05:41.060163: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0 1 2 2021-10-28 10:05:41.060189: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N N N 2021-10-28 10:05:41.060196: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 1: N N Y 2021-10-28 10:05:41.060205: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 2: N Y N # 省略一些显卡信息 Loaded model in 1.57s. Loading scorer from files deepspeech-0.9.3-models.scorer Loaded scorer in 0.000257s. Running inference. 2021-10-28 10:05:41.278758: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10 experience proves this Inference took 0.699s for 1.975s audio file.