FunASR icon indicating copy to clipboard operation
FunASR copied to clipboard

funasr_onnx 库加载标点模型(punc_ct-transformer_zh-cn-common-vocab272727-onnx)时抛出非标准异常,导致模型加载失败,最终标点恢复功能被禁用

Open GIS-hand opened this issue 1 month ago • 0 comments
trafficstars

Notice: In order to resolve issues more efficiently, please raise issue following the template. (注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)

🐛 Bug

To Reproduce

Steps to reproduce the behavior (always include the command you ran):

  1. 启动 Triton Inference Server 服务,命令示例:tritonserver --model-repository=/workspace/models --http-port=8000 --grpc-port=8001 --metrics-port=8002
  2. 服务初始化过程中,Triton 加载 feature_extractor(GPU 部署)、scoring(CPU 部署)及 punc_ct-transformer_zh-cn-common-vocab272727-onnx(标点模型)时,出现异常日志,标点模型加载失败。

Error Messages (from Logs)

I1023 08:31:46.439667 146 python_be.cc:2404] "TRITONBACKEND_ModelInstanceInitialize: feature_extractor_0_0 (GPU device 0)" I1023 08:31:46.439688 146 python_be.cc:2404] "TRITONBACKEND_ModelInstanceInitialize: feature_extractor_0_1 (GPU device 0)" I1023 08:31:46.441121 146 python_be.cc:2404] "TRITONBACKEND_ModelInstanceInitialize: scoring_0_0 (CPU device 0)" I1023 08:31:46.441141 146 python_be.cc:2404] "TRITONBACKEND_ModelInstanceInitialize: scoring_0_1 (CPU device 0)" I1023 08:31:47.663770 146 model.py:205] "Attempting to load punctuation model from specified path: /workspace/models/punc_ct-transformer_zh-cn-common-vocab272727-onnx" I1023 08:31:47.663831 146 model.py:208] "Model directory exists: /workspace/models/punc_ct-transformer_zh-cn-common-vocab272727-onnx" I1023 08:31:47.663988 146 model.py:211] "Model config file exists: /workspace/models/punc_ct-transformer_zh-cn-common-vocab272727-onnx/config.yaml" E1023 08:31:47.795854 146 model.py:236] "Unexpected error while loading punctuation model /workspace/models/punc_ct-transformer_zh-cn-common-vocab272727-onnx: funasr_onnx library threw non-standard exception: exceptions must derive from BaseException. This is a known issue in the funasr_onnx library. Consider updating the library or applying a patch. (type: RuntimeError)" W1023 08:31:47.795926 146 model.py:241] "Warning: No punctuation model loaded. Punctuation restoration will be

Code sample

(模型加载核心代码片段,来自 model.py 关键逻辑)

模型加载相关代码(示例,与日志中 model.py:205/208/211/236 对应)

def load_punctuation_model(model_path): print(f"Attempting to load punctuation model from specified path: {model_path}") if not os.path.exists(model_path): raise FileNotFoundError(f"Model directory not exists: {model_path}") print(f"Model directory exists: {model_path}")

config_path = os.path.join(model_path, "config.yaml")
if not os.path.exists(config_path):
    raise FileNotFoundError(f"Model config file not exists: {config_path}")
print(f"Model config file exists: {config_path}")

try:
    # 调用 funasr_onnx 加载模型的逻辑
    from funasr_onnx import Punctuation
    punc_model = Punctuation(model_dir=model_path)  # 此处抛出非标准异常
    return punc_model
except Exception as e:
    raise RuntimeError(
        f"Unexpected error while loading punctuation model {model_path}: funasr_onnx library threw non-standard exception: {str(e)}. This is a known issue in the funasr_onnx library. Consider updating the library or applying a patch."
    ) from e

Expected behavior

标点模型(punc_ct-transformer_zh-cn-common-vocab272727-onnx)应正常加载,Triton 服务初始化完成后,标点恢复功能可正常启用,无 Punctuation restoration will be disabled 警告。

Environment

  • OS (e.g., Linux): Ubuntu 20.04 LTS
  • FunASR Version (e.g., 1.0.0):
  • ModelScope Version (e.g., 1.11.0):
  • PyTorch Version (e.g., 2.0.0):
  • How you installed funasr (pip, source): pip install funasr_onnx
  • Python version: 3.10
  • GPU (e.g., V100M32) A10
  • CUDA/cuDNN version (e.g., cuda11.7):
  • Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1)
  • Any other relevant information:

Additional context

  1. 已确认标点模型目录(/workspace/models/punc_ct-transformer_zh-cn-common-vocab272727-onnx)及配置文件(config.yaml)存在,且模型文件(.onnx)未损坏。
  2. 异常提示 “funasr_onnx 抛出非标准异常(未继承 BaseException)” 为库已知问题,尝试过重新安装 funasr_onnx 但未解决,需确认是否有版本兼容或补丁方案。
  3. 目前仅标点恢复功能受影响,feature_extractor 和 scoring 模型可正常初始化。

GIS-hand avatar Oct 23 '25 08:10 GIS-hand