FunASR离线文件转写服务GPU版本支持华为昇腾910B么?
Notice: In order to resolve issues more efficiently, please raise issue following the template. (注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
❓ Questions and Help
Before asking:
- search the issues.
- search the docs.
What is your question?
Code
What have you tried?
What's your environment?
- OS (e.g., Linux):
- 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): - Python version:
- GPU (e.g., V100M32)
- CUDA/cuDNN version (e.g., cuda11.7):
- Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1)
- Any other relevant information:
这个转写服务用的onnx模型怎么都是量化后的模型
可以看下 https://github.com/k2-fsa/sherpa-onnx/pull/2697
@csukuangfj 遇到一个问题,请教一下: 我的机器是 910B2. 然后下载的权重是 sherpa-onnx-ascend-910B-sense-voice。如下 https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-ascend-910B-sense-voice-zh-en-ja-ko-yue-2025-09-09.tar.bz2
这个 bz2解压后自带 test_om.py 我运行了一下,报错如下:
root@910B-36:/sense-voice-910B# python test_om.py
[INFO] acl init success
[INFO] open device 0 success
[INFO] create new context
[ACL ERROR] EE1001: [PID: 106] 2025-10-30-08:21:08.817.477 The argument is invalid.Reason: ModelCheckCompatibility failed, supported socVersion=Ascend910B2, but the model socVersion=Ascend910B
Solution: 1.Check the input parameter range of the function. 2.Check the function invocation relationship.
TraceBack (most recent call last):
rtModelCheckCompatibility execute failed, reason=[soc version error][FUNC:FuncErrorReason][FILE:error_message_manage.cc][LINE:53]
Call rtModelCheckCompatibility(model_soc_version.c_str(), model_arch_type.c_str()) fail, ret: 0x7BC80[FUNC:CheckModelCompatibility][FILE:om_file_helper.cc][LINE:265]
Check model compatibility failed.[FUNC:LoadModelData][FILE:model_helper.cc][LINE:1266]
Assert ((GenerateGeRootModel(om_load_helper, model_data)) == ge::SUCCESS) failed[FUNC:LoadRootModel][FILE:model_helper.cc][LINE:1116]
Assert ((error_code) == ge::SUCCESS) failed[FUNC:LoadExecutorFromModelData][FILE:api.cc][LINE:123]
[Model][FromData]call gert::LoadExecutorFromModelDataWithMem load model from data failed, ge result[1343225857][FUNC:ReportCallError][FILE:log_inner.cpp][LINE:162]
[ERROR] load model from file failed, model file is ./model.om
[WARN] Check failed:processModel->LoadModelFromFile(modelPath), ret:1
[WARN] no model had been loaded, unload failed
Traceback (most recent call last):
File "/sense-voice-910B/test_om.py", line 148, in <module>
main()
File "/sense-voice-910B/test_om.py", line 95, in main
model = OmModel()
^^^^^^^^^
File "/sense-voice-910B/test_om.py", line 16, in __init__
self.model = InferSession(device_id=0, model_path="./model.om", debug=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.13/lib/python3.11/site-packages/ais_bench/infer/interface.py", line 82, in __init__
self.session = aclruntime.InferenceSession(self.model_path, self.device_id, self.options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: [1][ACL: invalid parameter]
关键:socVersion=Ascend910B2, but the model socVersion=Ascend910B 因此我尝试在当前的机器上,进行一次模型导出。
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx/scripts/sense-voice/ascend-npu
cp -r /data/models/iic/SenseVoiceSmall/* .
# pip install xxx 略
(.venv) root@910B-36: python export_onnx.py
saved to tokens.txt
loading model
/data2/project/wuzhongqin/funasr/.venv/lib/python3.10/site-packages/torch/onnx/_internal/jit_utils.py:307: UserWarning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied. (Triggered internally at /pytorch/torch/csrc/jit/passes/onnx/constant_fold.cpp:179.)
_C._jit_pass_onnx_node_shape_type_inference(node, params_dict, opset_version)
/data2/project/wuzhongqin/funasr/.venv/lib/python3.10/site-packages/torch/onnx/utils.py:702: UserWarning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied. (Triggered internally at /pytorch/torch/csrc/jit/passes/onnx/constant_fold.cpp:179.)
_C._jit_pass_onnx_graph_shape_type_inference(
/data2/project/wuzhongqin/funasr/.venv/lib/python3.10/site-packages/torch/onnx/utils.py:1208: UserWarning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied. (Triggered internally at /pytorch/torch/csrc/jit/passes/onnx/constant_fold.cpp:179.)
_C._jit_pass_onnx_graph_shape_type_inference(
saved to model.onnx
把 model.onnx 重命名 model.om 测试(源 tar.bz2中的 test_om.py)
python test_om.py
[INFO] acl init success
[INFO] open device 0 success
[INFO] create new context
[ACL ERROR] E10001: [PID: 188] 2025-10-30-09:47:26.425.915 Value [model] for parameter [om] is invalid. Reason: invalid om file
Solution: Try again with a valid argument.
TraceBack (most recent call last):
[Model][FromData]load model from data failed, ge result[145000][FUNC:ReportCallError][FILE:log_inner.cpp][LINE:162]
[ERROR] load model from file failed, model file is ./model.om
[WARN] Check failed:processModel->LoadModelFromFile(modelPath), ret:1
[WARN] no model had been loaded, unload failed
Traceback (most recent call last):
File "/sense-voice-910B/test_om.py", line 148, in <module>
main()
File "/sense-voice-910B/test_om.py", line 95, in main
model = OmModel()
^^^^^^^^^
File "/sense-voice-910B/test_om.py", line 16, in __init__
self.model = InferSession(device_id=0, model_path="./model.om", debug=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.13/lib/python3.11/site-packages/ais_bench/infer/interface.py", line 82, in __init__
self.session = aclruntime.InferenceSession(self.model_path, self.device_id, self.options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: [1][ACL: invalid parameter]
[INFO] end to reset device 0
[INFO] end to finalize acl
[ACL ERROR] EE1001: [PID: 106] 2025-10-30-08:21:08.817.477 The argument is invalid.Reason: ModelCheckCompatibility failed, supported socVersion=Ascend910B2, but the model socVersion=Ascend910B
稍等,我们导出910B2 的版本
把 model.onnx 重命名 model.om
真是人才
感谢回复,我对这些格式不懂。哈哈
正在导出,大概需要30分钟
请问是这个命令吗? atc --model=resnet50.onnx --framework=5 --output=resnet50 --input_shape="actual_input_1:1,3,224,224" --soc_version=<soc_version>
https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/800alpha001/quickstart/quickstart/quickstart_18_0010.html
no no no
这个是文档。https://k2-fsa.github.io/sherpa/onnx/ascend/export.html
但我觉得,对你太难了。你还是等我们转换好。
https://github.com/csukuangfj/sherpa-onnx/actions/runs/18936802577
等这个跑完,你再去同样的网页,下载 910B2 的模型就好了。
no no no
这个是文档。https://k2-fsa.github.io/sherpa/onnx/ascend/export.html
但我觉得,对你太难了。你还是等我们转换好。
留下了不争气的泪水
@zqWu
请去 https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models 下载 910B2 的模型,然后再测试下?
麻烦反馈下结果。
除了用里面的 test_om.py, 你还可以用我们写的 c++ 代码编译成的可执行程序。详见 https://k2-fsa.github.io/sherpa/onnx/ascend/install.html#build-sherpa-onnx
和
https://k2-fsa.github.io/sherpa/onnx/ascend/models.html#sherpa-onnx-ascend-910b-sense-voice-zh-en-ja-ko-yue-2024-07-17-chinese-english-japanese-korean-cantonese
(把里面的 910B 换成 910B2)
@csukuangfj python的 test_om.py 运行报错,我试试 c++程序再反馈
使用的是模型是
https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09.tar.bz2
./test_om.py
[INFO] acl init success
[INFO] open device 0 success
[INFO] create new context
[DEBUG] finish create context 0 in device 0
[ACL ERROR] E19999: Inner Error!
E19999: [PID: 339] 2025-10-31-01:40:11.840.283 Param:registry_holder is nullptr, check invalid[FUNC:GetOrCreateRegistry][FILE:op_impl_space_registry.cc][LINE:61]
TraceBack (most recent call last):
Assert ((space_registry->GetOrCreateRegistry(version_2_so_list.second, root_model->GetSoInOmInfo())) == ge::SUCCESS) failed[FUNC:GetSpaceRegistries][FILE:model_utils.cc][LINE:1559]
Assert ((ge::ModelUtils::GetSpaceRegistries(root_model, space_registries)) == ge::SUCCESS) failed[FUNC:CreateModelDesc][FILE:model_converter.cc][LINE:618]
Assert ((CreateModelDesc(root_model, stream_allocator, event_allocator, notify_allocator)) == ge::SUCCESS) failed[FUNC:ConvertGeModelToExecuteGraph][FILE:model_converter.cc][LINE:534]
Failed to lowering to execute graph[FUNC:LoadToModelV2ExecutorBuilder][FILE:api.cc][LINE:66]
Assert ((error_code) == ge::SUCCESS) failed[FUNC:LoadExecutorFromModelData][FILE:api.cc][LINE:123]
[Model][FromData]call gert::LoadExecutorFromModelDataWithMem load model from data failed, ge result[1343225857][FUNC:ReportCallError][FILE:log_inner.cpp][LINE:162]
[ERROR] load model from file failed, model file is ./model.om
[WARN] Check failed:processModel->LoadModelFromFile(modelPath), ret:1
[WARN] no model had been loaded, unload failed
Traceback (most recent call last):
File "/sense-voice-910B2/test_om.py", line 148, in <module>
main()
File "/sense-voice-910B2/test_om.py", line 95, in main
model = OmModel()
^^^^^^^^^
File "/sense-voice-910B2/test_om.py", line 16, in __init__
self.model = InferSession(device_id=0, model_path="./model.om", debug=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.13/lib/python3.11/site-packages/ais_bench/infer/interface.py", line 82, in __init__
self.session = aclruntime.InferenceSession(self.model_path, self.device_id, self.options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: [1][ACL: invalid parameter]
[DEBUG] end to destroy context 0 in device 0
[DEBUG] end to destroy contexts in device 0
[INFO] end to reset device 0
[DEBUG] not repeat acl init
[INFO] end to finalize acl
请问你的 cann 是8.0.0 吗?
我用的是 docker, image = quay.io/ascend/cann:8.3.rc1.alpha002-910b-ubuntu22.04-py3.11
我用的是 docker, image = quay.io/ascend/cann:8.3.rc1.alpha002-910b-ubuntu22.04-py3.11
我换 cann 8.0.0 试一下 请问一下,如果我在 cann8.3 环境,自己转换模型 ->onnx -> .om, 这个模型可以在 cann8.3环境中运行起来吗?
如果我在 cann8.3 环境,自己转换模型 ->onnx -> .om, 这个模型可以在 cann8.3环境中运行起来吗?
可以的! 因为我的环境是 cann 8.0.0, 所以才用的 8.0.0, 不然我没法测试。
你参考我上面发的链接,去转模型即可。你现在先用 8.0.0,验证没问题,再自己去转?
好了没
CANN8.0.0 测试ok。稍后补充一些细节,也能帮助一些刚接触这些的人
# 模型与 显卡类型有关,与 CANN版本有关
# 目前 提供的版本是 CANN 8.0.0 + 910B2
docker pull ascendai/cann:8.0.0-910b-ubuntu22.04-py3.9
ls -l
npu-tool-whl <=== 下载的 .whl文件 aclruntime-0.0.2-cp39-cp39-linux_aarch64.whl ais_bench-0.0.2-py3-none-any.whl
sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17 <== 下载的权重文件, 包含了 自测脚步和.wav
sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09 <== 下载的权重文件, 包含了 自测脚步和.wav
start_docker.sh
# start_docker.sh
IMAGE=ascendai/cann:8.0.0-910b-ubuntu22.04-py3.9
docker run -ti \
--name sense-voice \
--restart=unless-stopped \
--privileged=true \
--device /dev/davinci0 \
--device /dev/davinci1 \
--device /dev/davinci2 \
--device /dev/davinci3 \
--device /dev/davinci4 \
--device /dev/davinci5 \
--device /dev/davinci6 \
--device /dev/davinci7 \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
--network=host \
--ipc=host \
-v $PWD/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17:/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17 \
-v $PWD/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09:/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09 \
$IMAGE \
bash
# 容器中 安装 pip 依赖,以及 2个 .whl
pip install \
torch-npu==2.3.1.post6 \
kaldi_native_fbank \
numpy \
soundfile
# 在容器中测试
root@910B-36:/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09# cd /sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17/
root@910B-36:/sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17# ./test_om.py
[INFO] acl init success
[INFO] open device 0 success
[INFO] create new context
[INFO] load model ./model.om success
[INFO] create model description success
---model---
x dtype.float32 [1, -1, 560]
prompt dtype.int32 [4]
-----
/ctc_lo/Add:0:logits dtype.float32 [-1, -1, 25055]
features.shape (93, 560)
prompt (4,)
logits.shape (97, 25055) <class 'numpy.ndarray'>
[24884 25004 24993 25016 0 0 0 0 0 0 0 0
0 0 0 0 12227 0 0 0 13072 0 0 0
0 13161 0 0 18926 0 0 0 0 0 0 0
13153 0 0 9931 0 0 0 0 0 0 0 9699
0 0 0 14487 0 0 0 0 0 0 0 16535
0 0 0 0 0 0 0 0 0 9932 0 0
0 0 10686 0 0 0 0 0 9695 0 0 14487
0 0 0 0 0 0 0 0 0 0 0 0
9729]
97
[np.int64(24884), np.int64(25004), np.int64(24993), np.int64(25016), np.int64(12227), np.int64(13072), np.int64(13161), np.int64(18926), np.int64(13153), np.int64(9931), np.int64(9699), np.int64(14487), np.int64(16535), np.int64(9932), np.int64(10686), np.int64(9695), np.int64(14487), np.int64(9729)]
<|zh|><|NEUTRAL|><|Speech|><|withitn|>开放时间早上9点至下午5点。
[INFO] unload model success, model Id is 2147483648
[INFO] end to reset device 0
[INFO] end to finalize acl
# 2024-07-17 和 2025-09-09 都通过了自测
感谢分享!
可以用c++ 写的可执行程序去测试吗?需要你参考文档,从源码编译。 (要在你的 ascend npu 所在的机器去编译)
感谢分享!
可以用c++ 写的可执行程序去测试吗?需要你参考文档,从源码编译。 (要在你的 ascend npu 所在的机器去编译)
@csukuangfj
根据文档 https://k2-fsa.github.io/sherpa/onnx/ascend/install.html#build-sherpa-onnx 环境: IMAGE=quay.io/ascend/cann:8.3.rc1.alpha002-910b-ubuntu22.04-py3.11 显卡=910B2
build 结果符合预期
build 成功了,然后能运行么?
build 成功了,然后能运行么?
第一次 run 这个 ./bin/sherpa-onnx-offline, 稍等,我去下 onnx 权重
不需要下载 onnx 模型。你已经有 om 模型了。
https://k2-fsa.github.io/sherpa/onnx/ascend/models.html#sherpa-onnx-ascend-910b-sense-voice-zh-en-ja-ko-yue-2024-07-17-chinese-english-japanese-korean-cantonese
这里有使用方法.
用你下载的 910B2 模型。
复制、粘贴文档里的命令,就能跑。
复制、粘贴文档里的命令,就能跑。
两个权重都通过了 sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2025-09-09 sherpa-onnx-ascend-910B2-sense-voice-zh-en-ja-ko-yue-2024-07-17
感谢测试!
请问除了 910B2, 你还有什么 ascend npu 么? 我们可以提供对应的模型。
感谢测试!
请问除了 910B2, 你还有什么 ascend npu 么? 我们可以提供对应的模型。
感谢帮忙适配。现在没有其他卡了,如果下次遇到,再请教你