解决 whisper 在wsl 下的报错

14 min read

Traceback (most recent call last):
File "/mnt/c/Users/pan/whisper/bin/whisper", line 5, in
from whisper.transcribe import cli
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/whisper/init.py", line 13, in
from .model import ModelDimensions, Whisper
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/whisper/model.py", line 13, in
from .transcribe import transcribe as transcribe_function
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/whisper/transcribe.py", line 20, in
from .timing import add_word_timestamps
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/whisper/timing.py", line 7, in
import numba
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/numba/init.py", line 42, in
from numba.np.ufunc import (vectorize, guvectorize, threading_layer,
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/numba/np/ufunc/init.py", line 3, in
from numba.np.ufunc.decorators import Vectorize, GUVectorize, vectorize, guvectorize
File "/mnt/c/Users/pan/whisper/lib/python3.8/site-packages/numba/np/ufunc/decorators.py", line 3, in
from numba.np.ufunc import _internal
SystemError: initialization of _internal failed without raising an exception
这个错误是因为 numba 在 WSL 下可能会存在问题。为了解决这个问题,可以尝试以下步骤:

  1. 确保 WSL 中的 Python 已经安装了 numba。

  2. 在 WSL 中安装 LLVM:

    sudo apt-get install llvm
    
  3. 在 Windows 中安装 LLVM:

    下载 LLVM https://releases.llvm.org/download.html,选择 Windows 平台对应的版本。然后解压到一个目录,例如 C:\Program Files\LLVM

  4. 设置环境变量:

    在系统环境变量中添加一个新的变量 LLVM_CONFIG,将其值设置为 LLVM 的 llvm-config 可执行文件的路径,例如 C:\Program Files\LLVM\bin\llvm-config.exe

  5. 启动 WSL 终端,输入以下命令:

    export LLVM_CONFIG=/mnt/c/Program\ Files/LLVM/bin/llvm-config.exe
    
  6. 重新安装 numba:

    pip uninstall numba
    pip install numba
    
  7. 测试是否解决问题:

    whisper-create.py /opt/graphite/storage/whisper/test.wsp --xFilesFactor=0.5 --aggregationMethod=average 60:1440
    

    如果没有报错,则说明问题已经解决。