为更快的帮您定位问题,推荐您用以下模板反馈:
1、出现问题时,您做了哪些操作?
答复:执行命令
python3 infer_ds.py --model_path=SenseVoiceSmall --om_path=model_linux_aarch64.om --device=0 --input="./SenseVoiceSmall/example/zh.mp3"
2、在哪个步骤出现了问题?
答复:acl.mdl.execute报错
3、您希望得到什么结果?
答复:成功执行推理代码
4、您实际得到什么结果?
答复:推理失败返回错误码500002
5、请附上您出现问题页面的整屏截图或者日志信息;
日志信息如下
答复:(base) HwHiAiUser@orangepiaipro-20t:~/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice$ python3 infer_ds.py --model_path=SenseVoiceSmall --om_path=SenseVoice_linux_aarch64.om --device=0 --input="./SenseVoiceSmall/example/zh.mp3"
[INFO] RUNTIME(71011,python3):2025-02-01-12:36:58.604.446 [task_fail_callback_manager.cc:52] 71011 TaskFailCallBackManager: Constructor.
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.785 [msprof_callback_impl.cpp:336] >>> (tid:71011) Started to register profiling ctrl callback.
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.970 [msprof_callback_impl.cpp:343] >>> (tid:71011) Started to register profiling hash id callback.
[INFO] PROFILING(71011,python3):2025-02-01-12:36:58.691.985 [prof_atls_plugin.cpp:117] (tid:71011) RegisterProfileCallback, callback type is 7
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.993 [msprof_callback_impl.cpp:350] >>> (tid:71011) Started to register profiling enable host freq callback.
[INFO] PROFILING(71011,python3):2025-02-01-12:36:58.692.001 [prof_atls_plugin.cpp:117] (tid:71011) RegisterProfileCallback, callback type is 8
Loading remote code successfully: model
[INFO] PROFILING(71011,python3):2025-02-01-12:37:16.703.686 [prof_atls_plugin.cpp:210] (tid:71011) Module[48] register callback of ctrl handle.
[INFO] PROFILING(71011,python3):2025-02-01-12:37:16.703.729 [prof_atls_plugin.cpp:210] (tid:71011) Module[45] register callback of ctrl handle.
[INFO] GE(71011,python3):2025-02-01-12:37:16.958.493 [op_tiling_manager.cc:109]71011 ~FuncPerfScope:[GEPERFTRACE] The time cost of OpTilingManager::LoadSo is [254739] micro second.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.061.627 [runtime.cc:5471] 71011 GetVisibleDevices: ASCEND_RT_VISIBLE_DEVICES param was not set
[INFO] PROFILING(71011,python3):2025-02-01-12:37:18.063.994 [prof_atls_plugin.cpp:210] (tid:71011) Module[7] register callback of ctrl handle.
[EVENT] PROFILING(71011,python3):2025-02-01-12:37:18.064.086 [msprof_callback_impl.cpp:89] >>> (tid:71011) MsprofCtrlCallback called, type: 255
[EVENT] PROFILING(71011,python3):2025-02-01-12:37:18.064.537 [ai_drv_dev_api.cpp:333] >>> (tid:71011) Succeeded to DrvGetApiVersion version: 0x72313
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.831 [client_manager.cpp:462][GetClientRunMode][tid:71011] runningMode:0
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.846 [client_manager.cpp:126][GetInstance][tid:71011] [ClientManager] Current mode:2
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.857 [thread_mode_manager.cpp:70][Open][tid:71011] [ThreadModeManager] enter into open process deviceId[0] rankSize[0]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.065.719 [thread_mode_manager.cpp:280][HandleAICPUPackage][tid:71011] begin load aicpu package dstPath[/home/HwHiAiUser/], srcpath[/usr/local/Ascend/ascend-toolkit/latest/opp/Ascend/aicpu/] file[Ascend-aicpu_syskernels.tar.gz]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.065.743 [package_worker.cpp:338][LoadAICPUPackageForThreadMode][tid:71011] Package checkcode is [57460226]
[WARNING] TDT(71011,python3):2025-02-01-12:37:18.065.765 [package_worker.cpp:342][LoadAICPUPackageForThreadMode][tid:71011] Open aicpu_package_install.info verifyFile[/home/HwHiAiUser/aicpu_package_install.info], strerror[File exists]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.066.039 [thread_mode_manager.cpp:280][HandleAICPUPackage][tid:71011] begin load aicpu package dstPath[/home/HwHiAiUser/], srcpath[/usr/local/Ascend/ascend-toolkit/latest/opp/Ascend/aicpu/] file[Ascend-aicpu_extend_syskernels.tar.gz]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.066.059 [package_worker.cpp:338][LoadAICPUPackageForThreadMode][tid:71011] Package checkcode is [8052802]
[WARNING] TDT(71011,python3):2025-02-01-12:37:18.066.076 [package_worker.cpp:342][LoadAICPUPackageForThreadMode][tid:71011] Open aicpu_package_install.info verifyFile[/home/HwHiAiUser/extend_aicpu_package_install.info], strerror[File exists]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.142.306 [thread_mode_manager.cpp:159][SetAICPUProfilingCallback][tid:71011] [ThreadModeManager] profiling callback is nullptr, skip set aicpu profiling callback
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.350 [aicpusd_interface_process.cpp:525][TryGetLogLevelFromParentProcess][tid:71011] get ASCEND_GLOBAL_LOG_LEVEL [] and ASCEND_GLOBAL_EVENT_ENABLE []
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.545 [aicpusd_interface_process.cpp:467][GetCurrentRunMode][tid:71011] Current aicpu mode is offline (call by api).
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.576 [aicpusd_drv_manager.cpp:327][MarkMdc][tid:71011] Get hardware version[7] success.
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.594 [aicpusd_drv_manager.cpp:190][GetNormalAicpuInfo][tid:71011] aicpuBitMap[8], aicpuNum[1].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.607 [aicpusd_drv_manager.cpp:224][GetCcpuInfo][tid:71011] ccpuBitMap[7].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.636 [aicpusd_drv_manager.cpp:110][GetNormalAicpuDCpuInfo][tid:71011] GetNormalAicpuDCpuInfo, deviceId[0], aicpu_num[1], aicpu_os_sched[281470681743361], ccpu_num[255082402676739], ccpu_os_sched[255082402676737], dcpu_num[255082402676736], dcpu_os_sched[281470681743361], tscpu_num[187651416129536], tscpu_os_sched[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.650 [aicpusd_drv_manager.cpp:306][InitDrvMgrCaluniqueVfId][tid:71011] InitDrvMgr uniqueVfId=0, deviceId=0
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.658 [aicpusd_drv_manager.cpp:377][InitDrvMgr][tid:71011] host pid[71011], host proc name[], vf id[0], first aicpu index[0], aicpu num[1], dcpu base index[3], dcpu num[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.779 [aicpusd_resource_manager.cpp:257][InitBufManager][tid:71011] Aicpu schedule SetBuffCfg successed!
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.098 [aicpusd_worker.cpp:74][ThreadPool][tid:71011] ThreadPool
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.244 [aicpusd_worker.cpp:274][AddPidToTask][tid:71042] Bind pid by hal.
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.262 [aicpusd_worker.cpp:276][AddPidToTask][tid:71042] AddPidToTask by halBindCgroup
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.599 [aicpusd_worker.cpp:323][SetAffinityBySelf][tid:71042] [hw]SetAffinityBySelf, physIndex[3], devNum[0]
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.634 [aicpusd_worker.cpp:389][SetAffinity][tid:71042] aicpu bind tid by self, index[0], deviceId[0], res[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.869 [aicpusd_cust_so_manager.cpp:77][InitAicpuCustSoManager][tid:71011] cust so dir name is /home/HwHiAiUser/cust_aicpu_0_0_71011/.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.174.264 [raw_device.cc:237] 71011 Init: isAddrFlat:0
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.481 [grp_mng.c:81][bufmng] [halGrpCreate 81] Create grp. (grp_name=private_buff_grp_71011; grp_id=20; max_size=0; cache_flag=0)
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.509 [grp_mng.c:144][bufmng] [halGrpAddProc 144] add grp succ, name:private_buff_grp_71011, pid:71011, grp_id:20, admin:1 alloc:1 read:1 write:1
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.669 [buff_recycle.c:758][bufmng] [procMngInit 758] poolId 20 add task node uid 21 pid 71011
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.683 [drv_buff_mbuf.c:65][bufmng] [mbufSetPrivFlag 65] Set mbuf priv flag sucess. (flag=0, g_mbuf_priv_flag=0)
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.693 [grp_mng.c:212][bufmng] [halGrpAttach 212] grp attach, grp_name:private_buff_grp_71011, grp_id:20, timeout:1000
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.705 [drv_buff_memzone.c:450][bufmng] [memzone_cfg 450] BuffCfg success. (cfg num=4; huge_prior=393216; normal=393216; huge_only=393216; dvpp_huge_prior=393216; dvpp_normal=393216; dvpp_huge_only=393216)
[INFO] TDT(71011,python3):2025-02-01-12:37:18.176.648 [tsd_client.cpp:172][TsdCapabilityGet][tid:71011] TsdCapabilityGet Begin.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.176.672 [engine.cc:76] 71011 Engine: Constructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.176.681 [stars_engine.cc:41] 71011 StarsEngine: Constructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.179.568 [npu_driver.cc:5784] 71045 GetDeviceStatus: GetDeviceStatus status=1.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.180.535 [device_error_proc.cc:446] 71011 GetTschCapability: Tsch not support capability feature, use old solution.
[INFO] TDT(71011,python3):2025-02-01-12:37:18.180.583 [client_manager.cpp:195][SetProfilingCallback][tid:71011] [TsdClient] set profiling callback success
[INFO] GE(71011,python3):2025-02-01-12:37:33.947.513 [model_converter.cc:483]71011 CollectAndReserveStreamResource:Model SenseVoice require reusable stream num is 1 attached stream num is 0 event num is 0 notify num is 0.
[INFO] GE(71011,python3):2025-02-01-12:37:33.951.463 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libcust_opsproto_rt2.0.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:33.957.336 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libcust_opmaster_rt2.0.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.103.265 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopsproto_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.502.480 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopmaster_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.684.547 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopsproto_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:35.150.137 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopmaster_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:48.536.160 [graph_converter.cc:858]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::CreateMainNode is [12224825] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:48.717.261 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [181039] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:51.746.267 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [3028953] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.005 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [303691] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.047 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [303740] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.063 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.074 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.250.542 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [200454] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.914.345 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [663758] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.118 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [298724] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.161 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [298773] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.173 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.185 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [2] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.414.228 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [201028] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.947.252 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [532985] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.591 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [296295] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.634 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [296343] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.646 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.657 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [2] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.273.292 [graph_converter.cc:869]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::RunAllPass is [5737080] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:55.414.947 [graph_converter.cc:873]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::TopologicalSorting is [1141610] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.010.924 [graph_converter.cc:879]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::AppendGraphLevelData is [3343852] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.608.821 [graph_converter.cc:884]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::CalculatePriority is [597852] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.657.903 [graph_converter.cc:889]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::All is [23347894] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.153.327 [model_v2_executor_builder.cc:117]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::UpdateEquivalentEdges is [3388958] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.309.903 [model_v2_executor_builder.cc:120]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::AllocRootGraphAnyValues is [156532] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.336.468 [model_v2_executor_builder.cc:124]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInBuffer is [26523] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.350.451 [model_v2_executor_builder.cc:129]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInComputeNodeInfo is [13944] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.391.617 [model_v2_executor_builder.cc:134]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInKernelExtendInfo is [41127] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.394.524 [model_v2_executor_builder.cc:139]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInModelDesc is [2869] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:07.855.633 [model_v2_executor_builder.cc:170]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::BuildGraph is [4461077] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.040.420 [model_v2_executor_builder.cc:186]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::SubscribersSchedulerInit is [184712] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.040.464 [model_v2_executor_builder.cc:187]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::All is [8294500] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.994.388 [scalable_config.cc:74]71011 ScalableConfig:device total max size: 24823529472, page_mem_size_total_threshold: 23582352998, uncacheable_size_threshold: 17179869184
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:09.122.742 [tf_adpt_session_mgr.cc:393][CreateSession][tid:71042][TFAdapter][sessionID:9223372036854775808] Create session success.
[INFO] GE(71011,python3):2025-02-01-12:38:09.134.620 [davinci_model.cc:1337]71011 InitNodes:[GEPERFTRACE] The time cost of GraphLoader::InitTbeHandle. is [239] micro second, call num is 3
[INFO] GE(71011,python3):2025-02-01-12:38:09.134.658 [davinci_model.cc:1338]71011 InitNodes:[GEPERFTRACE] The time cost of DavinciModel::InitNodes is [1046] micro second.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:09.136.313 [api_error.cc:2431] 71011 ModelBindStream: model_id=0, stream_id=4, model_name=SenseVoice_sub_1_know, flag=0, group_id=255.
[INFO] GE(71011,python3):2025-02-01-12:38:09.138.819 [davinci_model.cc:927]71011 PrintfModelProfOfModelLoad:[GEPERFTRACE] The time cost of GraphLoader::DavinciModel::Init is [7571] micro second, name[SenseVoice_sub_1_know]model_id[4294967295]graph_id[0].
init resource success
Inputs: 4, Outputs: 2
Speech shape: torch.Size([1, 94, 560]), speech_lengths shape: torch.Size([1])
speech_np shape: (1, 94, 560), speech_lengths_np shape: (1,)
language shape: (1,), textnorm shape: (1,)
in 255086697884672 210560
in 255086698095616 4
in 255086698096640 4
in 255086698097152 4
out 255086698097152 0
out 255086698097152 0
[ERROR] GE(71011,python3):2025-02-01-12:38:13.791.132 [shape_utils.cc:35]71011 CalcAlignedSizeByShape: ErrorNo: 4294967295(failed) [EXEC][DEFAULT][Calc][TensorSizeByShape] shape_size[-560] data_type[DT_FLOAT] failed
[ERROR] ASCENDCL(71011,python3):2025-02-01-12:38:13.791.303 [model.cpp:757]71011 RuntimeV2ModelExecute: [EXEC][DEFAULT][Exec][Model]Execute model failed, ge result[4294967295], modelId[2147483648]
[ERROR] ASCENDCL(71011,python3):2025-02-01-12:38:13.791.446 [model.cpp:2104]71011 aclmdlExecute: [EXEC][DEFAULT][Exec][Model]modelId[2147483648] execute failed, result[500002]
Traceback (most recent call last):
File "/home/HwHiAiUser/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice/infer_ds.py", line 233, in <module>
res, _ = m.infer_acl(
File "/home/HwHiAiUser/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice/infer_ds.py", line 172, in infer_acl
assert ret == 0, f"推理执行失败,错误码: {ret}"
AssertionError: 推理执行失败,错误码: 500002
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:15.976.836 [aicpusd_worker.cpp:168][WaitForStop][tid:71011] WaitForStop begin.
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:18.377.743 [aicpusd_worker.cpp:174][WaitForStop][tid:71011] WaitForStop end.
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:18.421.848 [aicpusd_mpi_mgr.cpp:48][PrintStatisticInfo][tid:71011] Mpi Dvpp event statistic: [0]
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.186.871 [api_error.cc:2445] 71011 ModelUnbindStream: model_id=0, stream_id=4, model_name=SenseVoice_sub_1_know, group_id=255.
[INFO] GE(71011,python3):2025-02-01-12:38:24.187.397 [davinci_model.cc:7470]71011 LogModelDevMemInfo:model_metrics:name=SenseVoice_sub_1_know, alloc_dev_mem=1024 B, shared_dev_mem=0 B, device_id=0, rts_model_id=0
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.256 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_add_04a5147823af71da3a6df3f8cdf3fc248b872646296f63aa49aaa4b027cb69d72951db123d93246c68f633fd5550cc1368955c77a31aa01a2a7d23426e337bd8_static_bin] not found in stored.
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.301 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_cast_40ee5b4e88c86f609e9d5367a147bd9b03bcd04d985d7a00e60abf792fc5387ee016bc9f35e4743fa3a4e28e8d604856bc3583ac7a08c910e451e59c6000564c_static_bin] not found in stored.
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.334 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_cast_4978a1c9fe5106d2fbc311acae52d11bee65e963a8cf6d8e8c943b9bae3c383f565b533879a6576b3fbf762017264bf3d34b20211f13a666075ed5dc78255993_static_bin] not found in stored.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.579.272 [task_fail_callback_manager.cc:57] 71011 ~TaskFailCallBackManager: Destructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.580.692 [runtime.cc:2033] 71011 ~Runtime: deconstruct runtime
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.580.713 [runtime.cc:2040] 71011 ~Runtime: wait monitor success, use=0.
推理代码如下
# Copyright 2024 Huawei Technologies Co., Ltd
# (此处保留原有License声明,需根据实际需求调整)
import argparse
import time
import numpy as np
import torch
import acl
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank
# error code
ACL_SUCCESS = 0
# rule for mem
ACL_MEM_MALLOC_HUGE_FIRST = 0
ACL_MEM_MALLOC_HUGE_ONLY = 1
ACL_MEM_MALLOC_NORMAL_ONLY = 2
# rule for memory copy
ACL_MEMCPY_HOST_TO_HOST = 0
ACL_MEMCPY_HOST_TO_DEVICE = 1
ACL_MEMCPY_DEVICE_TO_HOST = 2
ACL_MEMCPY_DEVICE_TO_DEVICE = 3
def check_ret(message, ret):
if ret != ACL_SUCCESS:
raise Exception("{} failed ret={}"
.format(message, ret))
class SenseVoiceACLModel:
def __init__(self, device_id, om_path):
self.device_id = device_id
self.om_path = om_path
self.model_id = None
self.context = None
self.stream = None
self.blank_id = 0
self.lid_dict = {"auto": 0, "zh": 3, "en": 4, "yue": 7, "ja": 11, "ko": 12, "nospeech": 13}
self.textnorm_dict = {'withitn': 14, "woitn": 15}
self.input_data = []
self.output_data = []
# 初始化ACL环境
self._init_acl()
def _init_acl(self):
"""显式初始化ACL环境"""
# 初始化ACL
ret = acl.init()
assert ret == 0, f"ACL初始化失败,错误码: {ret}"
# 设置NPU设备
ret = acl.rt.set_device(self.device_id)
assert ret == 0, f"设置设备失败,错误码: {ret}"
# 创建Context和Stream
self.context, ret = acl.rt.create_context(self.device_id)
assert ret == 0, f"创建Context失败,错误码: {ret}"
self.stream, ret = acl.rt.create_stream()
assert ret == 0, f"创建Stream失败,错误码: {ret}"
# 加载OM模型
self.model_id, ret = acl.mdl.load_from_file(self.om_path)
assert ret == 0, f"模型加载失败,错误码: {ret}"
self.model_desc = acl.mdl.create_desc()
ret = acl.mdl.get_desc(self.model_desc, self.model_id)
check_ret("acl.mdl.get_desc", ret)
print("init resource success")
input_num = acl.mdl.get_num_inputs(self.model_desc)
output_num = acl.mdl.get_num_outputs(self.model_desc)
print(f"Inputs: {input_num}, Outputs: {output_num}")
def _destroy_acl(self):
"""释放ACL资源"""
if self.model_id:
acl.mdl.unload(self.model_id)
if self.stream:
acl.rt.free_stream(self.stream)
if self.context:
acl.rt.destroy_context(self.context)
acl.rt.reset_device(self.device_id)
acl.finalize()
def _gen_dataset(self, type_str="input"):
dataset = acl.mdl.create_dataset()
temp_dataset = None
if type_str == "in":
self.load_input_dataset = dataset
temp_dataset = self.input_data
else:
self.load_output_dataset = dataset
temp_dataset = self.output_data
for item in temp_dataset:
data = acl.create_data_buffer(item["buffer"], item["size"])
_, ret = acl.mdl.add_dataset_buffer(dataset, data)
print(type_str,item["buffer"], item["size"])
if ret != ACL_SUCCESS:
ret = acl.destroy_data_buffer(data)
check_ret("acl.destroy_data_buffer", ret)
def infer_acl(self, data_in,tokenizer=None,frontend=None, **kwargs):
"""手动管理ACL的推理逻辑"""
# 数据预处理(与原始代码相同)
audio_sample_list = load_audio_text_image_video(
data_in,
fs=frontend.fs,
audio_fs=kwargs.get("fs", 16000),
data_type=kwargs.get("data_type", "sound"),
tokenizer=tokenizer,
)
speech, speech_lengths = extract_fbank(
audio_sample_list, data_type=kwargs.get("data_type", "sound"), frontend=frontend
)
print(f"Speech shape: {speech.shape}, speech_lengths shape: {speech_lengths.shape}") # 添加调试信息
# 转换为NPU Tensor(假设数据已在CPU)
speech_np = speech.numpy().astype(np.float32)
speech_lengths_np = speech_lengths.numpy().astype(np.int32)
language = torch.LongTensor([self.lid_dict[kwargs.get("language", "auto")]]).numpy().astype(np.int32)
textnorm = torch.LongTensor([self.textnorm_dict["woitn"]]).numpy().astype(np.int32)
print(f"speech_np shape: {speech_np.shape}, speech_lengths_np shape: {speech_lengths_np.shape}")
print(f"language shape: {language.shape}, textnorm shape: {textnorm.shape}")
# 为输入数据分配Device内存
for data in [speech_np, speech_lengths_np, language, textnorm]:
size = data.nbytes
ptr = acl.util.bytes_to_ptr(data.tobytes())
buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST) # 在NPU上分配内存
assert ret == 0, f"内存分配失败,错误码: {ret}"
acl.rt.memcpy(buf, size, ptr, size, ACL_MEMCPY_HOST_TO_DEVICE)
self.input_data.append({"buffer": buf,
"size": size})
# 准备输出内存
output_size = acl.mdl.get_num_outputs(self.model_desc)
for i in range(output_size):
size = acl.mdl.get_output_size_by_index(self.model_desc, i)
# buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST)
# assert ret == 0, f"输出内存分配失败,错误码: {ret}"
self.output_data.append({"buffer": buf,
"size": 0})
'''
for size in output_sizes:
buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST)
assert ret == 0, f"输出内存分配失败,错误码: {ret}"
output_buffers.append(buf)
'''
# load input data into model
self._gen_dataset("in")
# load output data into model
self._gen_dataset("out")
# 执行推理
start_time = time.time()
ret = acl.mdl.execute(
self.model_id,
self.load_input_dataset,
self.load_output_dataset)
assert ret == 0, f"推理执行失败,错误码: {ret}"
cost_time = time.time() - start_time
# 从Device拷贝输出到Host
'''
outputs = []
for buf, size in zip(output_buffers, output_sizes):
host_buf = np.zeros(size // np.dtype(np.float32).itemsize, dtype=np.float32)
acl.rt.memcpy(host_buf.tobytes(), size, buf, size, ACL_MEMCPY_DEVICE_TO_HOST)
outputs.append(torch.from_numpy(host_buf).npu())
# 释放Device内存
for buf in input_buffers + output_buffers:
acl.rt.free(buf)
'''
outputs = []
for item in self.output_data:
host_buf = np.zeros(item["size"] // np.dtype(np.float32).itemsize, dtype=np.float32)
ret = acl.rt.memcpy(host_buf.tobytes(), item["size"], item["buffer"], item["size"], ACL_MEMCPY_DEVICE_TO_HOST)
assert ret == 0, f"数据拷贝失败,错误码: {ret}"
outputs.append(torch.from_numpy(host_buf).npu())
# 释放Device内存
for item in self.input_data + self.output_data:
acl.rt.free(item["buffer"])
# 后处理(与原始代码相同)
ctc_logits, encoder_out_lens = outputs[0], outputs[1]
results = []
x = ctc_logits[0, : encoder_out_lens[0].item(), :]
yseq = x.argmax(dim=-1)
yseq = torch.unique_consecutive(yseq, dim=-1)
mask = yseq != self.blank_id
token_int = yseq[mask].tolist()
text = tokenizer.decode(token_int)
results.append({"key": "wav_file_tmp_name", "text": text})
return results, cost_time
def __del__(self):
self._destroy_acl()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="SenseVoice ACL推理")
parser.add_argument("--model_path", type=str, help="PyTorch模型路径")
parser.add_argument('--om_path', type=str, help='OM模型路径')
parser.add_argument('--device', type=int, default=0, help='NPU设备ID')
parser.add_argument('--input', type=str, help='输入音频文件')
parser.add_argument('--perform', action='store_true', help='性能测试模式')
parser.add_argument('--loop', default=10, type=int, help='循环次数')
args = parser.parse_args()
# 加载PyTorch模型配置
_, kwargs = AutoModel.build_model(model=args.model_path, trust_remote_code=True)
# 初始化ACL推理器
m = SenseVoiceACLModel(device_id=args.device, om_path=args.om_path)
with torch.no_grad():
# 执行推理
res, _ = m.infer_acl(
data_in=args.input,
# tokenizer=kwargs["tokenizer"],
# frontend=kwargs["frontend"],
language="auto",
use_itn=False,
**kwargs
)
text = rich_transcription_postprocess(res[0]['text'])
print('语音输出:', text)
if args.perform:
total_time = 0.0
for _ in range(args.loop):
_, cost_time = m.infer_acl(
data_in=args.input,
tokenizer=kwargs["tokenizer"],
frontend=kwargs["frontend"],
language="auto",
use_itn=False,
**kwargs
)
total_time += cost_time
print(f'平均推理耗时: {total_time / args.loop:.4f}s')
为更快的帮您定位问题,推荐您用以下模板反馈:
1、出现问题时,您做了哪些操作?
答复:执行命令
python3 infer_ds.py --model_path=SenseVoiceSmall --om_path=model_linux_aarch64.om --device=0 --input="./SenseVoiceSmall/example/zh.mp3"
2、在哪个步骤出现了问题?
答复:acl.mdl.execute报错
3、您希望得到什么结果?
答复:成功执行推理代码
4、您实际得到什么结果?
答复:推理失败返回错误码500002
5、请附上您出现问题页面的整屏截图或者日志信息;
日志信息如下
答复:(base) HwHiAiUser@orangepiaipro-20t:~/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice$ python3 infer_ds.py --model_path=SenseVoiceSmall --om_path=SenseVoice_linux_aarch64.om --device=0 --input="./SenseVoiceSmall/example/zh.mp3"
[INFO] RUNTIME(71011,python3):2025-02-01-12:36:58.604.446 [task_fail_callback_manager.cc:52] 71011 TaskFailCallBackManager: Constructor.
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.785 [msprof_callback_impl.cpp:336] >>> (tid:71011) Started to register profiling ctrl callback.
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.970 [msprof_callback_impl.cpp:343] >>> (tid:71011) Started to register profiling hash id callback.
[INFO] PROFILING(71011,python3):2025-02-01-12:36:58.691.985 [prof_atls_plugin.cpp:117] (tid:71011) RegisterProfileCallback, callback type is 7
[EVENT] PROFILING(71011,python3):2025-02-01-12:36:58.691.993 [msprof_callback_impl.cpp:350] >>> (tid:71011) Started to register profiling enable host freq callback.
[INFO] PROFILING(71011,python3):2025-02-01-12:36:58.692.001 [prof_atls_plugin.cpp:117] (tid:71011) RegisterProfileCallback, callback type is 8
Loading remote code successfully: model
[INFO] PROFILING(71011,python3):2025-02-01-12:37:16.703.686 [prof_atls_plugin.cpp:210] (tid:71011) Module[48] register callback of ctrl handle.
[INFO] PROFILING(71011,python3):2025-02-01-12:37:16.703.729 [prof_atls_plugin.cpp:210] (tid:71011) Module[45] register callback of ctrl handle.
[INFO] GE(71011,python3):2025-02-01-12:37:16.958.493 [op_tiling_manager.cc:109]71011 ~FuncPerfScope:[GEPERFTRACE] The time cost of OpTilingManager::LoadSo is [254739] micro second.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.061.627 [runtime.cc:5471] 71011 GetVisibleDevices: ASCEND_RT_VISIBLE_DEVICES param was not set
[INFO] PROFILING(71011,python3):2025-02-01-12:37:18.063.994 [prof_atls_plugin.cpp:210] (tid:71011) Module[7] register callback of ctrl handle.
[EVENT] PROFILING(71011,python3):2025-02-01-12:37:18.064.086 [msprof_callback_impl.cpp:89] >>> (tid:71011) MsprofCtrlCallback called, type: 255
[EVENT] PROFILING(71011,python3):2025-02-01-12:37:18.064.537 [ai_drv_dev_api.cpp:333] >>> (tid:71011) Succeeded to DrvGetApiVersion version: 0x72313
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.831 [client_manager.cpp:462][GetClientRunMode][tid:71011] runningMode:0
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.846 [client_manager.cpp:126][GetInstance][tid:71011] [ClientManager] Current mode:2
[INFO] TDT(71011,python3):2025-02-01-12:37:18.064.857 [thread_mode_manager.cpp:70][Open][tid:71011] [ThreadModeManager] enter into open process deviceId[0] rankSize[0]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.065.719 [thread_mode_manager.cpp:280][HandleAICPUPackage][tid:71011] begin load aicpu package dstPath[/home/HwHiAiUser/], srcpath[/usr/local/Ascend/ascend-toolkit/latest/opp/Ascend/aicpu/] file[Ascend-aicpu_syskernels.tar.gz]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.065.743 [package_worker.cpp:338][LoadAICPUPackageForThreadMode][tid:71011] Package checkcode is [57460226]
[WARNING] TDT(71011,python3):2025-02-01-12:37:18.065.765 [package_worker.cpp:342][LoadAICPUPackageForThreadMode][tid:71011] Open aicpu_package_install.info verifyFile[/home/HwHiAiUser/aicpu_package_install.info], strerror[File exists]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.066.039 [thread_mode_manager.cpp:280][HandleAICPUPackage][tid:71011] begin load aicpu package dstPath[/home/HwHiAiUser/], srcpath[/usr/local/Ascend/ascend-toolkit/latest/opp/Ascend/aicpu/] file[Ascend-aicpu_extend_syskernels.tar.gz]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.066.059 [package_worker.cpp:338][LoadAICPUPackageForThreadMode][tid:71011] Package checkcode is [8052802]
[WARNING] TDT(71011,python3):2025-02-01-12:37:18.066.076 [package_worker.cpp:342][LoadAICPUPackageForThreadMode][tid:71011] Open aicpu_package_install.info verifyFile[/home/HwHiAiUser/extend_aicpu_package_install.info], strerror[File exists]
[INFO] TDT(71011,python3):2025-02-01-12:37:18.142.306 [thread_mode_manager.cpp:159][SetAICPUProfilingCallback][tid:71011] [ThreadModeManager] profiling callback is nullptr, skip set aicpu profiling callback
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.350 [aicpusd_interface_process.cpp:525][TryGetLogLevelFromParentProcess][tid:71011] get ASCEND_GLOBAL_LOG_LEVEL [] and ASCEND_GLOBAL_EVENT_ENABLE []
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.545 [aicpusd_interface_process.cpp:467][GetCurrentRunMode][tid:71011] Current aicpu mode is offline (call by api).
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.576 [aicpusd_drv_manager.cpp:327][MarkMdc][tid:71011] Get hardware version[7] success.
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.594 [aicpusd_drv_manager.cpp:190][GetNormalAicpuInfo][tid:71011] aicpuBitMap[8], aicpuNum[1].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.607 [aicpusd_drv_manager.cpp:224][GetCcpuInfo][tid:71011] ccpuBitMap[7].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.636 [aicpusd_drv_manager.cpp:110][GetNormalAicpuDCpuInfo][tid:71011] GetNormalAicpuDCpuInfo, deviceId[0], aicpu_num[1], aicpu_os_sched[281470681743361], ccpu_num[255082402676739], ccpu_os_sched[255082402676737], dcpu_num[255082402676736], dcpu_os_sched[281470681743361], tscpu_num[187651416129536], tscpu_os_sched[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.650 [aicpusd_drv_manager.cpp:306][InitDrvMgrCaluniqueVfId][tid:71011] InitDrvMgr uniqueVfId=0, deviceId=0
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.658 [aicpusd_drv_manager.cpp:377][InitDrvMgr][tid:71011] host pid[71011], host proc name[], vf id[0], first aicpu index[0], aicpu num[1], dcpu base index[3], dcpu num[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.142.779 [aicpusd_resource_manager.cpp:257][InitBufManager][tid:71011] Aicpu schedule SetBuffCfg successed!
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.098 [aicpusd_worker.cpp:74][ThreadPool][tid:71011] ThreadPool
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.244 [aicpusd_worker.cpp:274][AddPidToTask][tid:71042] Bind pid by hal.
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.143.262 [aicpusd_worker.cpp:276][AddPidToTask][tid:71042] AddPidToTask by halBindCgroup
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.599 [aicpusd_worker.cpp:323][SetAffinityBySelf][tid:71042] [hw]SetAffinityBySelf, physIndex[3], devNum[0]
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.634 [aicpusd_worker.cpp:389][SetAffinity][tid:71042] aicpu bind tid by self, index[0], deviceId[0], res[0].
[EVENT] CCECPU(71011,python3):2025-02-01-12:37:18.165.869 [aicpusd_cust_so_manager.cpp:77][InitAicpuCustSoManager][tid:71011] cust so dir name is /home/HwHiAiUser/cust_aicpu_0_0_71011/.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.174.264 [raw_device.cc:237] 71011 Init: isAddrFlat:0
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.481 [grp_mng.c:81][bufmng] [halGrpCreate 81] Create grp. (grp_name=private_buff_grp_71011; grp_id=20; max_size=0; cache_flag=0)
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.509 [grp_mng.c:144][bufmng] [halGrpAddProc 144] add grp succ, name:private_buff_grp_71011, pid:71011, grp_id:20, admin:1 alloc:1 read:1 write:1
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.669 [buff_recycle.c:758][bufmng] [procMngInit 758] poolId 20 add task node uid 21 pid 71011
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.683 [drv_buff_mbuf.c:65][bufmng] [mbufSetPrivFlag 65] Set mbuf priv flag sucess. (flag=0, g_mbuf_priv_flag=0)
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.693 [grp_mng.c:212][bufmng] [halGrpAttach 212] grp attach, grp_name:private_buff_grp_71011, grp_id:20, timeout:1000
[EVENT] DRV(71011,python3):2025-02-01-12:37:18.174.705 [drv_buff_memzone.c:450][bufmng] [memzone_cfg 450] BuffCfg success. (cfg num=4; huge_prior=393216; normal=393216; huge_only=393216; dvpp_huge_prior=393216; dvpp_normal=393216; dvpp_huge_only=393216)
[INFO] TDT(71011,python3):2025-02-01-12:37:18.176.648 [tsd_client.cpp:172][TsdCapabilityGet][tid:71011] TsdCapabilityGet Begin.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.176.672 [engine.cc:76] 71011 Engine: Constructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.176.681 [stars_engine.cc:41] 71011 StarsEngine: Constructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.179.568 [npu_driver.cc:5784] 71045 GetDeviceStatus: GetDeviceStatus status=1.
[INFO] RUNTIME(71011,python3):2025-02-01-12:37:18.180.535 [device_error_proc.cc:446] 71011 GetTschCapability: Tsch not support capability feature, use old solution.
[INFO] TDT(71011,python3):2025-02-01-12:37:18.180.583 [client_manager.cpp:195][SetProfilingCallback][tid:71011] [TsdClient] set profiling callback success
[INFO] GE(71011,python3):2025-02-01-12:37:33.947.513 [model_converter.cc:483]71011 CollectAndReserveStreamResource:Model SenseVoice require reusable stream num is 1 attached stream num is 0 event num is 0 notify num is 0.
[INFO] GE(71011,python3):2025-02-01-12:37:33.951.463 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libcust_opsproto_rt2.0.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:33.957.336 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libcust_opmaster_rt2.0.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.103.265 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopsproto_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.502.480 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopmaster_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:34.684.547 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopsproto_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:35.150.137 [op_impl_registry_holder_manager.cc:361]71011 GetOrCreateOpImplRegistryHolder:so has been loaded, so name: /libopmaster_rt.so, version:7.6.0.1.220, cpu:aarch64, os:linux
[INFO] GE(71011,python3):2025-02-01-12:37:48.536.160 [graph_converter.cc:858]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::CreateMainNode is [12224825] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:48.717.261 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [181039] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:51.746.267 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [3028953] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.005 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [303691] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.047 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [303740] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.063 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.050.074 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.250.542 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [200454] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:52.914.345 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [663758] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.118 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [298724] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.161 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [298773] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.173 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.213.185 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [2] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.414.228 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of ZeroCopy is [201028] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:53.947.252 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CEM is [532985] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.591 [copy_flow_launch_fuse.cc:499]71011 Run:[GEPERFTRACE] The time cost of Pass::CopyFlowLaunchFuse is [296295] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.634 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of CopyFlowLaunch is [296343] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.646 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of TrustOutTensor is [1] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.243.657 [base_optimizer.cc:63]71011 Run:[GEPERFTRACE] The time cost of AicpuFuseHostInputs is [2] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:54.273.292 [graph_converter.cc:869]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::RunAllPass is [5737080] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:55.414.947 [graph_converter.cc:873]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::TopologicalSorting is [1141610] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.010.924 [graph_converter.cc:879]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::AppendGraphLevelData is [3343852] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.608.821 [graph_converter.cc:884]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::CalculatePriority is [597852] micro second.
[INFO] GE(71011,python3):2025-02-01-12:37:59.657.903 [graph_converter.cc:889]71011 ConvertComputeGraphToExecuteGraph:[GEPERFTRACE] The time cost of ConvertComputeGraphToExecuteGraph::All is [23347894] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.153.327 [model_v2_executor_builder.cc:117]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::UpdateEquivalentEdges is [3388958] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.309.903 [model_v2_executor_builder.cc:120]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::AllocRootGraphAnyValues is [156532] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.336.468 [model_v2_executor_builder.cc:124]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInBuffer is [26523] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.350.451 [model_v2_executor_builder.cc:129]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInComputeNodeInfo is [13944] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.391.617 [model_v2_executor_builder.cc:134]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInKernelExtendInfo is [41127] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:03.394.524 [model_v2_executor_builder.cc:139]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::ReadInModelDesc is [2869] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:07.855.633 [model_v2_executor_builder.cc:170]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::BuildGraph is [4461077] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.040.420 [model_v2_executor_builder.cc:186]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::SubscribersSchedulerInit is [184712] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.040.464 [model_v2_executor_builder.cc:187]71011 Build:[GEPERFTRACE] The time cost of ModelV2ExecutorBuilderBuild::All is [8294500] micro second.
[INFO] GE(71011,python3):2025-02-01-12:38:08.994.388 [scalable_config.cc:74]71011 ScalableConfig:device total max size: 24823529472, page_mem_size_total_threshold: 23582352998, uncacheable_size_threshold: 17179869184
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:09.122.742 [tf_adpt_session_mgr.cc:393][CreateSession][tid:71042][TFAdapter][sessionID:9223372036854775808] Create session success.
[INFO] GE(71011,python3):2025-02-01-12:38:09.134.620 [davinci_model.cc:1337]71011 InitNodes:[GEPERFTRACE] The time cost of GraphLoader::InitTbeHandle. is [239] micro second, call num is 3
[INFO] GE(71011,python3):2025-02-01-12:38:09.134.658 [davinci_model.cc:1338]71011 InitNodes:[GEPERFTRACE] The time cost of DavinciModel::InitNodes is [1046] micro second.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:09.136.313 [api_error.cc:2431] 71011 ModelBindStream: model_id=0, stream_id=4, model_name=SenseVoice_sub_1_know, flag=0, group_id=255.
[INFO] GE(71011,python3):2025-02-01-12:38:09.138.819 [davinci_model.cc:927]71011 PrintfModelProfOfModelLoad:[GEPERFTRACE] The time cost of GraphLoader::DavinciModel::Init is [7571] micro second, name[SenseVoice_sub_1_know]model_id[4294967295]graph_id[0].
init resource success
Inputs: 4, Outputs: 2
Speech shape: torch.Size([1, 94, 560]), speech_lengths shape: torch.Size([1])
speech_np shape: (1, 94, 560), speech_lengths_np shape: (1,)
language shape: (1,), textnorm shape: (1,)
in 255086697884672 210560
in 255086698095616 4
in 255086698096640 4
in 255086698097152 4
out 255086698097152 0
out 255086698097152 0
[ERROR] GE(71011,python3):2025-02-01-12:38:13.791.132 [shape_utils.cc:35]71011 CalcAlignedSizeByShape: ErrorNo: 4294967295(failed) [EXEC][DEFAULT][Calc][TensorSizeByShape] shape_size[-560] data_type[DT_FLOAT] failed
[ERROR] ASCENDCL(71011,python3):2025-02-01-12:38:13.791.303 [model.cpp:757]71011 RuntimeV2ModelExecute: [EXEC][DEFAULT][Exec][Model]Execute model failed, ge result[4294967295], modelId[2147483648]
[ERROR] ASCENDCL(71011,python3):2025-02-01-12:38:13.791.446 [model.cpp:2104]71011 aclmdlExecute: [EXEC][DEFAULT][Exec][Model]modelId[2147483648] execute failed, result[500002]
Traceback (most recent call last):
File "/home/HwHiAiUser/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice/infer_ds.py", line 233, in <module>
res, _ = m.infer_acl(
File "/home/HwHiAiUser/ModelZoo-PyTorch/ACL_PyTorch/built-in/audio/SenseVoice/SenseVoice/infer_ds.py", line 172, in infer_acl
assert ret == 0, f"推理执行失败,错误码: {ret}"
AssertionError: 推理执行失败,错误码: 500002
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:15.976.836 [aicpusd_worker.cpp:168][WaitForStop][tid:71011] WaitForStop begin.
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:18.377.743 [aicpusd_worker.cpp:174][WaitForStop][tid:71011] WaitForStop end.
[EVENT] CCECPU(71011,python3):2025-02-01-12:38:18.421.848 [aicpusd_mpi_mgr.cpp:48][PrintStatisticInfo][tid:71011] Mpi Dvpp event statistic: [0]
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.186.871 [api_error.cc:2445] 71011 ModelUnbindStream: model_id=0, stream_id=4, model_name=SenseVoice_sub_1_know, group_id=255.
[INFO] GE(71011,python3):2025-02-01-12:38:24.187.397 [davinci_model.cc:7470]71011 LogModelDevMemInfo:model_metrics:name=SenseVoice_sub_1_know, alloc_dev_mem=1024 B, shared_dev_mem=0 B, device_id=0, rts_model_id=0
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.256 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_add_04a5147823af71da3a6df3f8cdf3fc248b872646296f63aa49aaa4b027cb69d72951db123d93246c68f633fd5550cc1368955c77a31aa01a2a7d23426e337bd8_static_bin] not found in stored.
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.301 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_cast_40ee5b4e88c86f609e9d5367a147bd9b03bcd04d985d7a00e60abf792fc5387ee016bc9f35e4743fa3a4e28e8d604856bc3583ac7a08c910e451e59c6000564c_static_bin] not found in stored.
[ERROR] GE(71011,python3):2025-02-01-12:38:24.188.334 [tbe_handle_store.cc:151]71011 EraseTBEHandle: ErrorNo: 1343225860(Internal errors) [Check][Param] Kernel[te_cast_4978a1c9fe5106d2fbc311acae52d11bee65e963a8cf6d8e8c943b9bae3c383f565b533879a6576b3fbf762017264bf3d34b20211f13a666075ed5dc78255993_static_bin] not found in stored.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.579.272 [task_fail_callback_manager.cc:57] 71011 ~TaskFailCallBackManager: Destructor.
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.580.692 [runtime.cc:2033] 71011 ~Runtime: deconstruct runtime
[INFO] RUNTIME(71011,python3):2025-02-01-12:38:24.580.713 [runtime.cc:2040] 71011 ~Runtime: wait monitor success, use=0.
推理代码如下
# Copyright 2024 Huawei Technologies Co., Ltd # (此处保留原有License声明,需根据实际需求调整) import argparse import time import numpy as np import torch import acl from funasr import AutoModel from funasr.utils.postprocess_utils import rich_transcription_postprocess from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank # error code ACL_SUCCESS = 0 # rule for mem ACL_MEM_MALLOC_HUGE_FIRST = 0 ACL_MEM_MALLOC_HUGE_ONLY = 1 ACL_MEM_MALLOC_NORMAL_ONLY = 2 # rule for memory copy ACL_MEMCPY_HOST_TO_HOST = 0 ACL_MEMCPY_HOST_TO_DEVICE = 1 ACL_MEMCPY_DEVICE_TO_HOST = 2 ACL_MEMCPY_DEVICE_TO_DEVICE = 3 def check_ret(message, ret): if ret != ACL_SUCCESS: raise Exception("{} failed ret={}" .format(message, ret)) class SenseVoiceACLModel: def __init__(self, device_id, om_path): self.device_id = device_id self.om_path = om_path self.model_id = None self.context = None self.stream = None self.blank_id = 0 self.lid_dict = {"auto": 0, "zh": 3, "en": 4, "yue": 7, "ja": 11, "ko": 12, "nospeech": 13} self.textnorm_dict = {'withitn': 14, "woitn": 15} self.input_data = [] self.output_data = [] # 初始化ACL环境 self._init_acl() def _init_acl(self): """显式初始化ACL环境""" # 初始化ACL ret = acl.init() assert ret == 0, f"ACL初始化失败,错误码: {ret}" # 设置NPU设备 ret = acl.rt.set_device(self.device_id) assert ret == 0, f"设置设备失败,错误码: {ret}" # 创建Context和Stream self.context, ret = acl.rt.create_context(self.device_id) assert ret == 0, f"创建Context失败,错误码: {ret}" self.stream, ret = acl.rt.create_stream() assert ret == 0, f"创建Stream失败,错误码: {ret}" # 加载OM模型 self.model_id, ret = acl.mdl.load_from_file(self.om_path) assert ret == 0, f"模型加载失败,错误码: {ret}" self.model_desc = acl.mdl.create_desc() ret = acl.mdl.get_desc(self.model_desc, self.model_id) check_ret("acl.mdl.get_desc", ret) print("init resource success") input_num = acl.mdl.get_num_inputs(self.model_desc) output_num = acl.mdl.get_num_outputs(self.model_desc) print(f"Inputs: {input_num}, Outputs: {output_num}") def _destroy_acl(self): """释放ACL资源""" if self.model_id: acl.mdl.unload(self.model_id) if self.stream: acl.rt.free_stream(self.stream) if self.context: acl.rt.destroy_context(self.context) acl.rt.reset_device(self.device_id) acl.finalize() def _gen_dataset(self, type_str="input"): dataset = acl.mdl.create_dataset() temp_dataset = None if type_str == "in": self.load_input_dataset = dataset temp_dataset = self.input_data else: self.load_output_dataset = dataset temp_dataset = self.output_data for item in temp_dataset: data = acl.create_data_buffer(item["buffer"], item["size"]) _, ret = acl.mdl.add_dataset_buffer(dataset, data) print(type_str,item["buffer"], item["size"]) if ret != ACL_SUCCESS: ret = acl.destroy_data_buffer(data) check_ret("acl.destroy_data_buffer", ret) def infer_acl(self, data_in,tokenizer=None,frontend=None, **kwargs): """手动管理ACL的推理逻辑""" # 数据预处理(与原始代码相同) audio_sample_list = load_audio_text_image_video( data_in, fs=frontend.fs, audio_fs=kwargs.get("fs", 16000), data_type=kwargs.get("data_type", "sound"), tokenizer=tokenizer, ) speech, speech_lengths = extract_fbank( audio_sample_list, data_type=kwargs.get("data_type", "sound"), frontend=frontend ) print(f"Speech shape: {speech.shape}, speech_lengths shape: {speech_lengths.shape}") # 添加调试信息 # 转换为NPU Tensor(假设数据已在CPU) speech_np = speech.numpy().astype(np.float32) speech_lengths_np = speech_lengths.numpy().astype(np.int32) language = torch.LongTensor([self.lid_dict[kwargs.get("language", "auto")]]).numpy().astype(np.int32) textnorm = torch.LongTensor([self.textnorm_dict["woitn"]]).numpy().astype(np.int32) print(f"speech_np shape: {speech_np.shape}, speech_lengths_np shape: {speech_lengths_np.shape}") print(f"language shape: {language.shape}, textnorm shape: {textnorm.shape}") # 为输入数据分配Device内存 for data in [speech_np, speech_lengths_np, language, textnorm]: size = data.nbytes ptr = acl.util.bytes_to_ptr(data.tobytes()) buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST) # 在NPU上分配内存 assert ret == 0, f"内存分配失败,错误码: {ret}" acl.rt.memcpy(buf, size, ptr, size, ACL_MEMCPY_HOST_TO_DEVICE) self.input_data.append({"buffer": buf, "size": size}) # 准备输出内存 output_size = acl.mdl.get_num_outputs(self.model_desc) for i in range(output_size): size = acl.mdl.get_output_size_by_index(self.model_desc, i) # buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST) # assert ret == 0, f"输出内存分配失败,错误码: {ret}" self.output_data.append({"buffer": buf, "size": 0}) ''' for size in output_sizes: buf, ret = acl.rt.malloc(size, ACL_MEM_MALLOC_HUGE_FIRST) assert ret == 0, f"输出内存分配失败,错误码: {ret}" output_buffers.append(buf) ''' # load input data into model self._gen_dataset("in") # load output data into model self._gen_dataset("out") # 执行推理 start_time = time.time() ret = acl.mdl.execute( self.model_id, self.load_input_dataset, self.load_output_dataset) assert ret == 0, f"推理执行失败,错误码: {ret}" cost_time = time.time() - start_time # 从Device拷贝输出到Host ''' outputs = [] for buf, size in zip(output_buffers, output_sizes): host_buf = np.zeros(size // np.dtype(np.float32).itemsize, dtype=np.float32) acl.rt.memcpy(host_buf.tobytes(), size, buf, size, ACL_MEMCPY_DEVICE_TO_HOST) outputs.append(torch.from_numpy(host_buf).npu()) # 释放Device内存 for buf in input_buffers + output_buffers: acl.rt.free(buf) ''' outputs = [] for item in self.output_data: host_buf = np.zeros(item["size"] // np.dtype(np.float32).itemsize, dtype=np.float32) ret = acl.rt.memcpy(host_buf.tobytes(), item["size"], item["buffer"], item["size"], ACL_MEMCPY_DEVICE_TO_HOST) assert ret == 0, f"数据拷贝失败,错误码: {ret}" outputs.append(torch.from_numpy(host_buf).npu()) # 释放Device内存 for item in self.input_data + self.output_data: acl.rt.free(item["buffer"]) # 后处理(与原始代码相同) ctc_logits, encoder_out_lens = outputs[0], outputs[1] results = [] x = ctc_logits[0, : encoder_out_lens[0].item(), :] yseq = x.argmax(dim=-1) yseq = torch.unique_consecutive(yseq, dim=-1) mask = yseq != self.blank_id token_int = yseq[mask].tolist() text = tokenizer.decode(token_int) results.append({"key": "wav_file_tmp_name", "text": text}) return results, cost_time def __del__(self): self._destroy_acl() if __name__ == '__main__': parser = argparse.ArgumentParser(description="SenseVoice ACL推理") parser.add_argument("--model_path", type=str, help="PyTorch模型路径") parser.add_argument('--om_path', type=str, help='OM模型路径') parser.add_argument('--device', type=int, default=0, help='NPU设备ID') parser.add_argument('--input', type=str, help='输入音频文件') parser.add_argument('--perform', action='store_true', help='性能测试模式') parser.add_argument('--loop', default=10, type=int, help='循环次数') args = parser.parse_args() # 加载PyTorch模型配置 _, kwargs = AutoModel.build_model(model=args.model_path, trust_remote_code=True) # 初始化ACL推理器 m = SenseVoiceACLModel(device_id=args.device, om_path=args.om_path) with torch.no_grad(): # 执行推理 res, _ = m.infer_acl( data_in=args.input, # tokenizer=kwargs["tokenizer"], # frontend=kwargs["frontend"], language="auto", use_itn=False, **kwargs ) text = rich_transcription_postprocess(res[0]['text']) print('语音输出:', text) if args.perform: total_time = 0.0 for _ in range(args.loop): _, cost_time = m.infer_acl( data_in=args.input, tokenizer=kwargs["tokenizer"], frontend=kwargs["frontend"], language="auto", use_itn=False, **kwargs ) total_time += cost_time print(f'平均推理耗时: {total_time / args.loop:.4f}s')