Fun-ASR-Nano-2512、SenseVoice复合流水线的 NPU 性能/兼容性

未關閉
#3,825 9 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
18/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
活躍
技術堆疊
python, pytorch

研究方向

The reporter's script patches seg_pooling on funasr.models.campplus.components.CAMLayer and runs SenseVoiceSmall, FSMN-VAD, CAM++ and punctuation models on npu:0, then compares it with a CPU run. The NPU log shows repeated 'tiling offset out of range' and 64-bit 'High Accuracy but Low Performance' warnings, and the real-time factor is about 29 on NPU versus 0.07 on CPU. Done would mean a reproducible explanation of the NPU slowdown, or a documented fix for the operators that fall back to slow paths. This needs Ascend and FunASR internals, so it is not a starter task.

由索引模型根據 Issue 內容生成。

描述

needs triage question

SenseVoice 模型验证

环境信息
例如:

操作系统 :x86
昇腾硬件信息:300IPro
CANN软件版本:8.5.1
安装的对应软件版本:
torch 2.7.1+cpu
torch-complex 0.4.4
torch_npu 2.7.1.post2
torchaudio 2.7.1+cpu

🐛 问题描述
脚本如下:
`import os
import time
import wave
import torch
import torch_npu # 显式导入以触发 NPU 初始化
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
from funasr.models.campplus import components as cp

============================================================
0. 昇腾 NPU 环境前置优化
设置可见的 NPU 设备
os.environ.setdefault("ASCEND_RT_VISIBLE_DEVICES", "0")

开启任务队列流水优化,提升 CPU 下发任务的效率
os.environ.setdefault("TASK_QUEUE_ENABLE", "2")

针对昇腾开启混合精度(FP16),大幅提升吞吐并节省内存
torch.npu.set_autocast_enabled(True)
torch.npu.set_autocast_dtype(torch.float16)

强制使用预编译算子,跳过首次运行的 JIT 在线编译耗时
torch_npu.npu.set_compile_mode(jit_compile=False)
torch_npu.npu.config.allow_internal_format = False

============================================================
CAM++ 昇腾 NPU 兼容补丁
def seg_pooling(self, x, seg_len=100, stype="avg"):
if stype not in ("avg", "max"):
raise ValueError("Wrong segment pooling type.") # 修复原代码缩进与拼写错误

B, C, T = x.shape
n_full = T // seg_len
tail = T - n_full * seg_len
segs = []

if n_full > 0:
full = x[:, :, :n_full * seg_len].reshape(
B, C, n_full, seg_len
)
if stype == "avg":
segs.append(full.mean(dim=-1))
else:
segs.append(full.max(dim=-1).values)

if tail > 0:
tail_x = x[:, :, n_full * seg_len:]
if stype == "avg":
segs.append(tail_x.mean(dim=-1, keepdim=True))
else:
segs.append(tail_x.max(dim=-1, keepdim=True).values)

seg = torch.cat(segs, dim=-1) if len(segs) > 1 else segs[0]
shape = seg.shape
seg = seg.unsqueeze(-1).expand(*shape, seg_len).reshape(
*shape[:-1], -1
)
return seg[..., :T]

cp.CAMLayer.seg_pooling = seg_pooling
print("CAM++ NPU seg_pooling 补丁已加载")

audio_path = "1787544302.850033_16k.wav"

if not os.path.isfile(audio_path):
raise FileNotFoundError(f"音频文件不存在:{audio_path}")

获取 WAV 音频时长
audio_duration = None
try:
with wave.open(audio_path, "rb") as wf: # 修复原代码缩进错误
audio_duration = wf.getnframes() / wf.getframerate()
except Exception as e:
print(f"无法直接读取 WAV 时长,将在推理后继续统计:{e}")

组合:语音识别 + VAD + 说话人识别 + 标点
print("\n========== 开始加载模型 ==========")
load_start = time.perf_counter()

model = AutoModel(
model="/iic--SenseVoiceSmall/snapshots/master",
vad_model="/iic--speech_fsmn_vad_zh-cn-16k-common-pytorch/snapshots/master",
spk_model="/iic--speech_campplus_sv_zh-cn_16k-common/snapshots/master",
punc_model="/iic--punc_ct-transformer_zh-cn-common-vocab272727-pytorch/snapshots/master",
device="npu:0",
disable_update=True
)

load_end = time.perf_counter()
load_time = load_end - load_start

print(f"模型加载完成,耗时:{load_time:.2f} 秒")
print(model)

============================================================

NPU Warmup (预热)

print("\n========== 开始 NPU 预热 ==========")
warmup_start = time.perf_counter()
try:
构造一个模拟输入进行空跑,提前触发底层算子初始化与编译
dummy_input = torch.randn(1, 16000, device="npu:0", dtype=torch.float16)
for _ in range(3):
_ = model.generate(input=dummy_input, batch_size_s=1)
torch.npu.synchronize()
print(f"NPU 预热完成,耗时:{time.perf_counter() - warmup_start:.2f} 秒")
except Exception as e:
print(f"预热跳过或失败(可能不支持随机张量输入):{e}")

============================================================
2. 推理耗时
print("\n========== 开始音频推理 ==========")
infer_start = time.perf_counter()

result = model.generate(
input=audio_path,
batch_size_s=60,
)

等待 NPU 异步任务完成,避免低估推理时间
try:
torch.npu.synchronize()
except (AttributeError, RuntimeError):
pass

infer_end = time.perf_counter()
infer_time = infer_end - infer_start

print(f"音频推理完成,耗时:{infer_time:.2f} 秒")

============================================================
3. 输出识别结果
print("\n========== 识别结果 ==========")

segments = result[0].get("sentence_info", []) if result else []

for seg in segments:
start = seg["start"] / 1000
end = seg["end"] / 1000
speaker = seg.get("spk", "未知")
text = rich_transcription_postprocess(
seg.get("sentence", seg.get("text", ""))
)

print(
f"[{start:.2f}s - {end:.2f}s] "
f"说话人{speaker}: {text}"
)

============================================================
4. 性能统计
print("\n========== 性能统计 ===========")

if audio_duration is not None and audio_duration > 0:
rtf = infer_time / audio_duration
speed = audio_duration / infer_time if infer_time > 0 else 0

print(f"音频时长: {audio_duration:.2f} 秒")
print(f"模型加载耗时: {load_time:.2f} 秒")
print(f"本条推理耗时: {infer_time:.2f} 秒")
print(f"端到端耗时: {load_time + infer_time:.2f} 秒")
print(f"实时率 RTF: {rtf:.3f}")
print(f"处理速度: {speed:.3f} 倍实时")

if rtf > 1:
print("性能说明:处理速度慢于实时播放速度。")
else:
print("性能说明:处理速度快于实时播放速度。")

else:
print(f"模型加载耗时: {load_time:.2f} 秒")
print(f"本条推理耗时: {infer_time:.2f} 秒")
print("音频时长未能读取,暂无法计算实时率。")`

npu性能如下:
/opt/conda/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu

brew install ffmpeg # mac
CAM++ NPU seg_pooling 补丁已加载

========== 开始加载模型 ==========
funasr version: 1.3.14.
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
..模型加载完成,耗时:45.71 秒
<funasr.auto.auto_model.AutoModel object at 0x7f931d903190>

========== 开始音频推理 ==========
0%| | 0/1 [00:00<?, ?it/s]..Warning: tiling offset out of range, index: 32
...Warning: tiling offset out of range, index: 32
rtf_avg: 1.696: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [01:00<00:00, 60.88s/it]
0%| | 0/1 [00:00<?, ?it/s].....Warning: tiling offset out of range, index: 32 | 0/3 [00:00<?, ?it/s]
...Warning: tiling offset out of range, index: 32
..Warning: tiling offset out of range, index: 32
....[W1026 16:01:18.019485585 NeKernelNpu.cpp:47] Warning: The oprator of ne is executed, Currently High Accuracy but Low Performance OP with 64-bit has been used, Please Do Some Cast at Python Functions with 32-bit for Better Performance! (function operator())
[W1026 16:01:22.230408447 OpCommand.cpp:83] Warning: [Check][offset] Check input storage_offset[%ld] = 0 failed, result is untrustworthy100220 (function operator())
.[W1026 16:01:30.142395213 NeKernelNpu.cpp:29] Warning: The oprator of ne is executed, Currently High Accuracy but Low Performance OP with 64-bit has been used, Please Do Some Cast at Python Functions with 32-bit for Better Performance! (function operator())
[W1026 16:01:31.310202985 AddKernelNpu.cpp:82] Warning: The oprator of add is executed, Currently High Accuracy but Low Performance OP with 64-bit has been used, Please Do Some Cast at Python Functions with 32-bit for Better Performance! (function operator())
..[W1026 16:01:46.339537243 GatherKernelNpu.cpp:33] Warning: The oprator of gather is executed, Currently High Accuracy but Low Performance OPwith 64-bit has been used,Please Do Some Cast at Python Functions with 32-bit for Better Performance! (function operator())
rtf_avg: 9.343: 100%|████████████████████████████████████████████████████████████████████████████████████████| 3/3 [03:43<00:00, 74.37s/it]
rtf_avg: 0.027: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 24.38it/s]
rtf_avg: 0.027: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 24.61it/s].rtf_avg: 11.424: 100%|███████████████████████████████████████████████████████████████████████████████████████| 9/9 [02:34<00:00, 17.14s/it]
rtf_avg: 11.424: 100%|███████████████████████████████████████████████████████████████████████████████████████| 9/9 [02:34<00:00, 17.14s/it]Warning: tiling offset out of range, index: 32 | 0/22 [00:00<?, ?it/s]
rtf_avg: 4.996: 100%|██████████████████████████████████████████████████████████████████████████████████████| 22/22 [02:44<00:00, 7.49s/it]
rtf_avg: 4.996: 100%|██████████████████████████████████████████████████████████████████████████████████████| 22/22 [02:44<00:00, 7.49s/it]Warning: tiling offset out of range, index: 32 | 0/1 [00:00<?, ?it/s]
rtf_avg: -447.966: 100%|████████████████████████████████████████████████████████████████████████████████████| 1/1 [07:27<00:00, 447.97s/it]
WARNING:root:length mismatch between punc and timestamp█████████████████████████████████████████████████████| 1/1 [07:27<00:00, 447.97s/it]
rtf_avg: 27.588, time_speech: 35.920, time_escape: 990.963: 100%|██████████████████████████████████████████| 1/1 [16:30<00:00, 990.97s/it]
音频推理完成,耗时:1051.86 秒

========== 识别结果 ==========
[0.00s - 11.48s] 说话人1: y喂你好不是什么车啊您好帮联系一下那个车主好吧就别😊您到小地方车牌二,
[11.54s - 11.84s] 说话人1: a 二,
[11.90s - 13.76s] 说话人1: a d e a b 的?
[13.88s - 14.12s] 说话人3: b e,
[14.48s - 16.34s] 说话人3: b e 零五五六零五五六后两车转机中请再过来,
[16.40s - 16.70s] 说话人3: ,
[17.06s - 21.73s] 说话人1: ,
[23.29s - 35.83s] 说话人4: 。

========== 性能统计 ==========
音频时长: 35.92 秒
模型加载耗时: 45.71 秒
本条推理耗时: 1051.86 秒
端到端耗时: 1097.57 秒
实时率 RTF: 29.283
处理速度: 0.034 倍实时
性能说明:处理速度慢于实时播放速度。

cpu性能如下:
反而cpu下跑会更快。
/opt/conda/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu

brew install ffmpeg # mac
CAM++ NPU seg_pooling 补丁已加载

========== 开始加载模型 ==========
funasr version: 1.3.14.
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
WARNING:root:trust_remote_code: False
模型加载完成,耗时:4.48 秒
<funasr.auto.auto_model.AutoModel object at 0x7f24a3f7e200>

========== 开始音频推理 ==========
rtf_avg: 0.004: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 7.09it/s]
rtf_avg: 0.408: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 5.81it/s]
rtf_avg: 0.054: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 12.31it/s]
rtf_avg: 0.062: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 2.38it/s]
rtf_avg: 0.013: 100%|████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 50.80it/s]
rtf_avg: 0.050: 100%|████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.21it/s]
rtf_avg: 0.010: 100%|██████████████████████████████████████████████████████████████████████████████████████| 22/22 [00:00<00:00, 68.44it/s]
rtf_avg: -0.034: 100%|███████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 28.76it/s]
WARNING:root:length mismatch between punc and timestamp██████████████████████████████████████████████████████| 1/1 [00:00<00:00, 29.02it/s]
rtf_avg: 0.065, time_speech: 35.920, time_escape: 2.344: 100%|██████████████████████████████████████████████| 1/1 [00:02<00:00, 2.35s/it]
音频推理完成,耗时:2.50 秒

========== 识别结果 ==========
[0.00s - 11.48s] 说话人1: y喂你好不是什么车啊您好帮联系一下那个车主好吧就别😊您到小地方车牌二,
[11.54s - 11.84s] 说话人1: a 二,
[11.90s - 13.76s] 说话人1: a d e a b 的?
[13.88s - 14.12s] 说话人3: b e,
[14.48s - 16.34s] 说话人3: b e 零五五六零五五六后两车转机中请再过来,
[16.40s - 16.70s] 说话人3: ,
[17.06s - 21.73s] 说话人1: ,
[23.29s - 35.83s] 说话人4: 。

========== 性能统计 ==========
音频时长: 35.92 秒
模型加载耗时: 4.48 秒
本条推理耗时: 2.50 秒
端到端耗时: 6.98 秒
实时率 RTF: 0.070
处理速度: 14.365 倍实时
性能说明:处理速度快于实时播放速度。

Fun-ASR-Nano-2512模型验证

脚本:
"""Fun-ASR-Nano 最小验证;检查模型放置设备,底层算子仍可能回退 CPU。"""
import argparse
import importlib.metadata
import json
import sys
import time
from datetime import datetime, timedelta, timezone
from pathlib import Path

def stage(message):
print(f"[阶段] {message}", flush=True)
# 容器常见的 cgroup v2 / v1 路径。这里只读,缺失或无权限时跳过。
for filename in (
"/sys/fs/cgroup/memory.current", "/sys/fs/cgroup/memory.max",
"/sys/fs/cgroup/memory.events",
"/sys/fs/cgroup/memory/memory.usage_in_bytes",
"/sys/fs/cgroup/memory/memory.limit_in_bytes",
"/sys/fs/cgroup/memory/memory.failcnt",
):
try:
print(filename, Path(filename).read_text().strip().replace("\n", "; "), flush=True)
except OSError:
pass

def main():
test_start = time.perf_counter()
test_started_at = datetime.now(timezone(timedelta(hours=8))).isoformat(timespec="seconds")
parser = argparse.ArgumentParser(description=doc)
parser.add_argument("--audio", help="16 kHz 单声道 WAV;--check-only 时无需提供")
parser.add_argument("--model", default="FunAudioLLM/Fun-ASR-Nano-2512")
parser.add_argument("--device", default="npu:0", help="npu:0 或 cpu")
parser.add_argument("--check-only", action="store_true")
parser.add_argument("--repeat", type=int, default=1)
parser.add_argument("--llm-dtype", choices=["fp32", "fp16", "bf16"], default="fp32")
parser.add_argument("--attention", choices=["eager", "sdpa"], default="eager",
help="Qwen attention 后端;默认 eager,验证绕过当前 310P3 SDPA 错误")
args = parser.parse_args()
if args.repeat < 1:
parser.error("--repeat 必须大于 0")
if not args.check_only and not args.audio:
parser.error("请提供 --audio")

print("Python:", sys.version, "executable:", sys.executable, flush=True)
for package in ("torch", "torch-npu", "torchaudio", "funasr", "transformers", "modelscope"):
    try:
        print(package, importlib.metadata.version(package), flush=True)
    except importlib.metadata.PackageNotFoundError:
        print(package, "未安装", flush=True)

stage("即将 import torch(默认可能自动加载 NPU 插件)")
import torch
stage("import torch 完成")

if args.device.startswith("npu"):
    stage("即将 import torch_npu")
    import torch_npu  # 注册 NPU 后端;必须在加载 FunASR 前导入
    stage("import torch_npu 完成;即将查询 is_available")

    if not torch.npu.is_available():
        raise RuntimeError("NPU 不可用;先检查驱动、CANN 环境变量及容器设备映射")
    stage("即将 set_device")
    torch.npu.set_device(args.device)
    stage("set_device 完成;即将查询设备名称")
    print("NPU:", torch.npu.get_device_name(), flush=True)
    # 单独验证实际分配、矩阵乘法和同步;is_available() 不足以证明算子可运行。
    stage("即将创建 NPU 张量")
    x = torch.ones((16, 16), device=args.device)
    stage("即将执行 NPU 矩阵乘法及同步")
    value = (x @ x).sum().item()
    torch.npu.synchronize()
    if value != 4096.0:
        raise RuntimeError(f"NPU 矩阵乘法结果异常: {value}")
    print("NPU FP32 matmul: PASS", flush=True)
elif args.device != "cpu":
    parser.error("此 demo 仅接受 npu 设备或 cpu")

if args.check_only:
    print(f"基础检查耗时:{time.perf_counter() - test_start:.3f} 秒", flush=True)
    return

import soundfile as sf
from funasr import AutoModel

audio_path = Path(args.audio).expanduser().resolve(strict=True)
audio_start = time.perf_counter()
audio, sample_rate = sf.read(str(audio_path), dtype="float32")
if sample_rate != 16000 or audio.ndim != 1 or len(audio) == 0:
    raise ValueError("请使用非空、16 kHz、单声道 WAV")
duration = len(audio) / sample_rate
# Nano.generate_chatml 接受路径或 torch.Tensor,不接受 numpy.ndarray。
# 保留在 CPU,后续由 FunASR 特征提取和设备搬运路径处理。
audio_tensor = torch.from_numpy(audio)
audio_load_s = time.perf_counter() - audio_start
if args.device.startswith("npu"):
    torch.npu.synchronize()
start = time.perf_counter()
# 使用包内实现,不指定 remote_code,避免加载另一个尚未修复的 model.py。
model = AutoModel(model=args.model, device=args.device, hub="ms", disable_update=True)
if args.device.startswith("npu"):
    torch.npu.synchronize()
model_load_s = time.perf_counter() - start
print(f"音频时长:{duration:.3f} 秒;音频读取耗时:{audio_load_s:.3f} 秒", flush=True)
print(f"模型加载耗时:{model_load_s:.3f} 秒", flush=True)
llm = getattr(model.model, "llm", None)
if llm is None or not hasattr(llm, "set_attn_implementation"):
    raise RuntimeError("当前模型未提供 LLM attention 切换接口,请核对 Transformers 和模型实现")
llm.set_attn_implementation(args.attention)
print("LLM attention:", llm.config._attn_implementation, flush=True)
devices = sorted({str(p.device) for p in model.model.parameters()})
print("模型参数设备:", devices, flush=True)
if args.device.startswith("npu") and not any(d.startswith("npu") for d in devices):
    raise RuntimeError("模型参数未放到 NPU,停止,避免把 CPU 运行误判为 NPU 成功")

inference_times = []
for index in range(args.repeat):
    if args.device.startswith("npu"):
        torch.npu.synchronize()
    run_started_at = datetime.now(timezone(timedelta(hours=8))).isoformat(timespec="seconds")
    print(f"\n第 {index + 1}/{args.repeat} 轮开始:{run_started_at}", flush=True)
    start = time.perf_counter()
    with torch.inference_mode():
        result = model.generate(
            input=[audio_tensor], cache={}, batch_size=1, language="中文", itn=True,
            llm_dtype=args.llm_dtype,
        )
    if args.device.startswith("npu"):
        torch.npu.synchronize()
    elapsed = time.perf_counter() - start
    inference_times.append(elapsed)
    run_finished_at = datetime.now(timezone(timedelta(hours=8))).isoformat(timespec="seconds")
    print(f"第 {index + 1} 轮结束:{run_finished_at}\n"
          f"推理耗时:{elapsed:.3f} 秒({elapsed / 60:.2f} 分钟)\n"
          f"RTF:{elapsed / duration:.4f};处理速度:{duration / elapsed:.4f} 倍实时",
          flush=True)
    print(json.dumps({"run": index + 1, "audio_s": duration,
                      "started_at": run_started_at, "finished_at": run_finished_at,
                      "inference_s": elapsed, "rtf": elapsed / duration,
                      "result": result}, ensure_ascii=False, default=str), flush=True)

total_inference_s = sum(inference_times)
mean_inference_s = total_inference_s / len(inference_times)
total_s = time.perf_counter() - test_start
print("\n========== 测试时间汇总 ==========", flush=True)
print(f"测试开始(北京时间):{test_started_at}\n"
      f"测试结束(北京时间):{datetime.now(timezone(timedelta(hours=8))).isoformat(timespec='seconds')}\n"
      f"设备:{args.device};attention:{args.attention};LLM 精度:{args.llm_dtype}\n"
      f"单条音频时长:{duration:.3f} 秒;测试轮数:{args.repeat}\n"
      f"模型加载耗时:{model_load_s:.3f} 秒\n"
      f"首轮推理耗时:{inference_times[0]:.3f} 秒\n"
      f"全部轮次平均推理耗时:{mean_inference_s:.3f} 秒\n"
      f"全部轮次平均 RTF:{mean_inference_s / duration:.4f}\n"
      f"推理累计耗时:{total_inference_s:.3f} 秒\n"
      f"脚本总耗时(main 开始至汇总前):{total_s:.3f} 秒({total_s / 60:.2f} 分钟)",
      flush=True)
if len(inference_times) > 1:
    subsequent_mean_s = sum(inference_times[1:]) / (len(inference_times) - 1)
    print(f"排除首轮后的平均推理耗时:{subsequent_mean_s:.3f} 秒\n"
          f"排除首轮后的平均 RTF:{subsequent_mean_s / duration:.4f}", flush=True)
print("推理计时包含特征提取、模型解码及 generate 内的后处理和 NPU 同步;"
      "不含模型加载、WAV 读取和结果打印。脚本总耗时包含环境初始化、加载及结果打印。",
      flush=True)

if name == "main":
main()

日志
python -u fun_asr_npu_demo.py --model /home/bml/storage/mnt/v-3qcoydvt6ftns41n/org/model2/FunAudioLLM--Fun-ASR-Nano-2512/snapshots/master --audio /home/bml/storage/mnt/v-3qcoydvt6ftns41n/org/134.200.46.9_5090-1787544302.850033_16k.wav --device cpu --repeat 2
Python: 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] executable: /opt/conda/bin/python
torch 2.7.1+cpu
torch-npu 2.7.1.post2
torchaudio 2.7.1+cpu
funasr 1.4.14
transformers 5.20.2
modelscope 1.40.2
[阶段] 即将 import torch(默认可能自动加载 NPU 插件)
/sys/fs/cgroup/memory/memory.usage_in_bytes 3002576896
/sys/fs/cgroup/memory/memory.limit_in_bytes 17179869184
/sys/fs/cgroup/memory/memory.failcnt 0
[阶段] import torch 完成
/sys/fs/cgroup/memory/memory.usage_in_bytes 3752804352
/sys/fs/cgroup/memory/memory.limit_in_bytes 17179869184
/sys/fs/cgroup/memory/memory.failcnt 0
/opt/conda/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu
# brew install ffmpeg # mac
funasr version: 1.4.14.
2026-10-30 18:24:30,012 [INFO] download models from model hub: ms
2026-10-30 18:24:30,065 [WARNING] trust_remote_code: False
2026-10-30 18:25:15,626 [INFO] rank: 0, model is builded.
2026-10-30 18:25:15,628 [INFO] Loading pretrained params from /home/bml/storage/mnt/v-3qcoydvt6ftns41n/org/model2/FunAudioLLM--Fun-ASR-Nano-2512/snapshots/master/model.pt
2026-10-30 18:25:15,638 [INFO] ckpt: /home/bml/storage/mnt/v-3qcoydvt6ftns41n/org/model2/FunAudioLLM--Fun-ASR-Nano-2512/snapshots/master/model.pt
2026-10-30 18:25:17,444 [INFO] scope_map: ['module.', 'None']
2026-10-30 18:25:17,444 [INFO] excludes: None
2026-10-30 18:25:17,691 [INFO] Loading ckpt: /home/bml/storage/mnt/v-3qcoydvt6ftns41n/org/model2/FunAudioLLM--Fun-ASR-Nano-2512/snapshots/master/model.pt, status:
音频时长:35.920 秒;音频读取耗时:0.003 秒
模型加载耗时:49.930 秒
LLM attention: eager
模型参数设备: ['cpu']

第 1/2 轮开始:2026-10-30T18:25:19+08:00
rtf_avg: 0.096: 100%|█████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.47s/it]
第 1 轮结束:2026-10-30T18:25:23+08:00
推理耗时:3.503 秒(0.06 分钟)
RTF:0.0975;处理速度:10.2543 倍实时
{"run": 1, "audio_s": 35.92, "started_at": "2026-10-30T18:25:19+08:00", "finished_at": "2026-10-30T18:25:23+08:00", "inference_s": 3.5029310695827007, "rtf": 0.0975203527166676, "result": [{"key": "rand_key_2yW4Acq9GFz6Y", "text": "喂,你好,不是什么车牌。", "text_tn": "喂你好不是什么车牌", "label": "null", "ctc_text": "微你好不是什么出牌好你帮联系一下那个车主好吧就点您报小地方车牌二 a二 a e a 的 b e零五五零五五六好了你在转机中请下过", "ctc_timestamps": [{"token": "微", "start_time": 11.34, "end_time": 11.4, "score": 0.766}, {"token": "你", "start_time": 11.46, "end_time": 11.52, "score": 0.664}, {"token": "好", "start_time": 11.58, "end_time": 11.64, "score": 0.71}, {"token": "不", "start_time": 11.88, "end_time": 11.94, "score": 0.815}, {"token": "是", "start_time": 11.94, "end_time": 12.0, "score": 0.876}, {"token": "什", "start_time": 12.12, "end_time": 12.18, "score": 0.287}, {"token": "么", "start_time": 12.24, "end_time": 12.3, "score": 0.572}, {"token": "出", "start_time": 12.42, "end_time": 12.48, "score": 0.615}, {"token": "牌", "start_time": 12.6, "end_time": 12.66, "score": 0.716}, {"token": "好", "start_time": 13.56, "end_time": 13.62, "score": 0.122}, {"token": "你", "start_time": 13.8, "end_time": 13.86, "score": 0.504}, {"token": "帮", "start_time": 14.1, "end_time": 14.16, "score": 0.554}, {"token": "联", "start_time": 14.64, "end_time": 14.7, "score": 0.984}, {"token": "系", "start_time": 14.82, "end_time": 14.88, "score": 0.997}, {"token": "一", "start_time": 14.94, "end_time": 15.06, "score": 0.999}, {"token": "下", "start_time": 15.06, "end_time": 15.12, "score": 1.0}, {"token": "那", "start_time": 15.24, "end_time": 15.3, "score": 0.978}, {"token": "个", "start_time": 15.42, "end_time": 15.48, "score": 0.984}, {"token": "车", "start_time": 15.96, "end_time": 16.02, "score": 0.996}, {"token": "主", "start_time": 16.14, "end_time": 16.2, "score": 0.999}, {"token": "好", "start_time": 16.38, "end_time": 16.44, "score": 0.999}, {"token": "吧", "start_time": 16.5, "end_time": 16.56, "score": 0.931}, {"token": "就", "start_time": 16.68, "end_time": 16.74, "score": 0.976}, {"token": "点", "start_time": 17.16, "end_time": 17.22, "score": 0.161}, {"token": "您", "start_time": 19.5, "end_time": 19.56, "score": 0.865}, {"token": "报", "start_time": 19.74, "end_time": 19.8, "score": 0.673}, {"token": "小", "start_time": 20.04, "end_time": 20.1, "score": 0.842}, {"token": "地", "start_time": 20.22, "end_time": 20.28, "score": 0.857}, {"token": "方", "start_time": 20.28, "end_time": 20.34, "score": 0.987}, {"token": "车", "start_time": 20.52, "end_time": 20.58, "score": 0.348}, {"token": "牌", "start_time": 20.7, "end_time": 20.76, "score": 0.645}, {"token": "二", "start_time": 21.48, "end_time": 21.54, "score": 0.828}, {"token": " a", "start_time": 21.78, "end_time": 21.84, "score": 0.53}, {"token": "二", "start_time": 23.34, "end_time": 23.4, "score": 0.702}, {"token": " a", "start_time": 23.64, "end_time": 23.7, "score": 0.528}, {"token": " e", "start_time": 24.84, "end_time": 24.9, "score": 0.507}, {"token": " a", "start_time": 25.14, "end_time": 25.2, "score": 0.363}, {"token": " ", "start_time": 25.38, "end_time": 25.44, "score": 0.633}, {"token": "的", "start_time": 25.5, "end_time": 25.56, "score": 0.986}, {"token": " b", "start_time": 25.62, "end_time": 25.68, "score": 0.523}, {"token": " e", "start_time": 29.1, "end_time": 29.16, "score": 0.462}, {"token": "零", "start_time": 29.94, "end_time": 30.0, "score": 0.945}, {"token": "五", "start_time": 30.24, "end_time": 30.3, "score": 0.989}, {"token": "五", "start_time": 30.48, "end_time": 30.54, "score": 0.989}, {"token": "零", "start_time": 31.98, "end_time": 32.04, "score": 0.922}, {"token": "五", "start_time": 32.28, "end_time": 32.34, "score": 0.993}, {"token": "五", "start_time": 32.64, "end_time": 32.7, "score": 0.985}, {"token": "六", "start_time": 32.88, "end_time": 33.0, "score": 0.978}, {"token": "好", "start_time": 34.44, "end_time": 34.5, "score": 0.756}, {"token": "了", "start_time": 34.56, "end_time": 34.62, "score": 0.212}, {"token": "你", "start_time": 34.68, "end_time": 34.74, "score": 0.525}, {"token": "在", "start_time": 34.8, "end_time": 34.86, "score": 0.33}, {"token": "转", "start_time": 34.92, "end_time": 34.98, "score": 0.302}, {"token": "机", "start_time": 35.1, "end_time": 35.16, "score": 0.825}, {"token": "中", "start_time": 35.22, "end_time": 35.28, "score": 0.881}, {"token": "请", "start_time": 35.4, "end_time": 35.46, "score": 0.437}, {"token": "下", "start_time": 35.52, "end_time": 35.58, "score": 0.243}, {"token": "过", "start_time": 35.7, "end_time": 35.76, "score": 0.779}], "timestamps": [{"token": "喂", "start_time": 11.28, "end_time": 11.34, "score": 0.007}, {"token": ",", "start_time": 11.34, "end_time": 11.4, "score": 0.0}, {"token": "你", "start_time": 11.46, "end_time": 11.52, "score": 0.664}, {"token": "好", "start_time": 11.58, "end_time": 11.64, "score": 0.71}, {"token": ",", "start_time": 11.76, "end_time": 11.82, "score": 0.0}, {"token": "不", "start_time": 11.88, "end_time": 11.94, "score": 0.815}, {"token": "是", "start_time": 11.94, "end_time": 12.0, "score": 0.876}, {"token": "什", "start_time": 12.12, "end_time": 12.18, "score": 0.287}, {"token": "么", "start_time": 12.24, "end_time": 12.3, "score": 0.572}, {"token": "车", "start_time": 15.96, "end_time": 16.02, "score": 0.996}, {"token": "牌", "start_time": 20.7, "end_time": 20.76, "score": 0.645}, {"token": "。", "start_time": 21.48, "end_time": 21.54, "score": 0.0}]}]}

第 2/2 轮开始:2026-10-30T18:25:23+08:00
rtf_avg: 0.178: 100%|█████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:06<00:00, 6.38s/it]
第 2 轮结束:2026-10-30T18:25:29+08:00
推理耗时:6.382 秒(0.11 分钟)
RTF:0.1777;处理速度:5.6281 倍实时
{"run": 2, "audio_s": 35.92, "started_at": "2026-10-30T18:25:23+08:00", "finished_at": "2026-10-30T18:25:29+08:00", "inference_s": 6.382224903441966, "rtf": 0.17767886702232644, "result": [{"key": "rand_key_1t9EwL56nGisi", "text": "喂,你好,不是什么车牌哦,你好,帮我联系一下那个车主,好吧,就编您报一下对方车牌二A二A B E A B的B E B E零五五六零五五六。", "text_tn": "喂你好不是什么车牌哦你好帮我联系一下那个车主好吧就编您报一下对方车牌二A二A B E A B的B E B E零五五六零五五六", "label": "null", "ctc_text": "喂你好不是什么出牌好你帮联系一下那个车主好吧就您报小地方车牌二 a二 a e a 的 b e零五五零五五六好了你在转机中请下过", "ctc_timestamps": [{"token": "喂", "start_time": 11.28, "end_time": 11.34, "score": 0.516}, {"token": "你", "start_time": 11.46, "end_time": 11.52, "score": 0.756}, {"token": "好", "start_time": 11.58, "end_time": 11.64, "score": 0.873}, {"token": "不", "start_time": 11.88, "end_time": 11.94, "score": 0.821}, {"token": "是", "start_time": 11.94, "end_time": 12.0, "score": 0.878}, {"token": "什", "start_time": 12.12, "end_time": 12.18, "score": 0.273}, {"token": "么", "start_time": 12.24, "end_time": 12.3, "score": 0.593}, {"token": "出", "start_time": 12.42, "end_time": 12.48, "score": 0.6}, {"token": "牌", "start_time": 12.6, "end_time": 12.66, "score": 0.841}, {"token": "好", "start_time": 13.56, "end_time": 13.62, "score": 0.137}, {"token": "你", "start_time": 13.8, "end_time": 13.86, "score": 0.551}, {"token": "帮", "start_time": 14.1, "end_time": 14.16, "score": 0.585}, {"token": "联", "start_time": 14.64, "end_time": 14.7, "score": 0.976}, {"token": "系", "start_time": 14.82, "end_time": 14.88, "score": 0.997}, {"token": "一", "start_time": 14.94, "end_time": 15.06, "score": 0.999}, {"token": "下", "start_time": 15.06, "end_time": 15.12, "score": 1.0}, {"token": "那", "start_time": 15.24, "end_time": 15.3, "score": 0.979}, {"token": "个", "start_time": 15.42, "end_time": 15.48, "score": 0.985}, {"token": "车", "start_time": 15.96, "end_time": 16.02, "score": 0.996}, {"token": "主", "start_time": 16.14, "end_time": 16.2, "score": 0.999}, {"token": "好", "start_time": 16.38, "end_time": 16.44, "score": 0.999}, {"token": "吧", "start_time": 16.5, "end_time": 16.56, "score": 0.92}, {"token": "就", "start_time": 16.68, "end_time": 16.74, "score": 0.978}, {"token": "您", "start_time": 19.5, "end_time": 19.56, "score": 0.883}, {"token": "报", "start_time": 19.74, "end_time": 19.8, "score": 0.741}, {"token": "小", "start_time": 20.04, "end_time": 20.1, "score": 0.863}, {"token": "地", "start_time": 20.22, "end_time": 20.28, "score": 0.854}, {"token": "方", "start_time": 20.28, "end_time": 20.34, "score": 0.987}, {"token": "车", "start_time": 20.52, "end_time": 20.58, "score": 0.391}, {"token": "牌", "start_time": 20.7, "end_time": 20.76, "score": 0.803}, {"token": "二", "start_time": 21.48, "end_time": 21.54, "score": 0.861}, {"token": " a", "start_time": 21.78, "end_time": 21.84, "score": 0.578}, {"token": "二", "start_time": 23.34, "end_time": 23.4, "score": 0.743}, {"token": " a", "start_time": 23.64, "end_time": 23.7, "score": 0.499}, {"token": " e", "start_time": 24.84, "end_time": 24.9, "score": 0.534}, {"token": " a", "start_time": 25.14, "end_time": 25.2, "score": 0.393}, {"token": " ", "start_time": 25.38, "end_time": 25.44, "score": 0.649}, {"token": "的", "start_time": 25.5, "end_time": 25.56, "score": 0.986}, {"token": " b", "start_time": 25.62, "end_time": 25.68, "score": 0.509}, {"token": " e", "start_time": 29.1, "end_time": 29.16, "score": 0.479}, {"token": "零", "start_time": 29.94, "end_time": 30.0, "score": 0.943}, {"token": "五", "start_time": 30.24, "end_time": 30.3, "score": 0.988}, {"token": "五", "start_time": 30.48, "end_time": 30.54, "score": 0.988}, {"token": "零", "start_time": 31.98, "end_time": 32.04, "score": 0.917}, {"token": "五", "start_time": 32.28, "end_time": 32.34, "score": 0.993}, {"token": "五", "start_time": 32.64, "end_time": 32.7, "score": 0.986}, {"token": "六", "start_time": 32.88, "end_time": 33.0, "score": 0.983}, {"token": "好", "start_time": 34.44, "end_time": 34.5, "score": 0.818}, {"token": "了", "start_time": 34.56, "end_time": 34.62, "score": 0.235}, {"token": "你", "start_time": 34.68, "end_time": 34.74, "score": 0.577}, {"token": "在", "start_time": 34.8, "end_time": 34.86, "score": 0.47}, {"token": "转", "start_time": 34.92, "end_time": 34.98, "score": 0.387}, {"token": "机", "start_time": 35.1, "end_time": 35.16, "score": 0.852}, {"token": "中", "start_time": 35.22, "end_time": 35.28, "score": 0.905}, {"token": "请", "start_time": 35.4, "end_time": 35.46, "score": 0.556}, {"token": "下", "start_time": 35.52, "end_time": 35.58, "score": 0.24}, {"token": "过", "start_time": 35.7, "end_time": 35.76, "score": 0.724}], "timestamps": [{"token": "喂", "start_time": 11.28, "end_time": 11.34, "score": 0.516}, {"token": ",", "start_time": 11.46, "end_time": 11.52, "score": 0.0}, {"token": "你", "start_time": 11.52, "end_time": 11.58, "score": 0.026}, {"token": "好", "start_time": 11.58, "end_time": 11.64, "score": 0.873}, {"token": ",", "start_time": 11.7, "end_time": 11.76, "score": 0.0}, {"token": "不", "start_time": 11.88, "end_time": 11.94, "score": 0.821}, {"token": "是", "start_time": 11.94, "end_time": 12.0, "score": 0.878}, {"token": "什", "start_time": 12.12, "end_time": 12.18, "score": 0.273}, {"token": "么", "start_time": 12.24, "end_time": 12.3, "score": 0.593}, {"token": "车", "start_time": 12.42, "end_time": 12.48, "score": 0.163}, {"token": "牌", "start_time": 12.6, "end_time": 12.66, "score": 0.841}, {"token": "哦", "start_time": 13.56, "end_time": 13.62, "score": 0.031}, {"token": ",", "start_time": 13.68, "end_time": 13.74, "score": 0.0}, {"token": "你", "start_time": 13.8, "end_time": 13.86, "score": 0.551}, {"token": "好", "start_time": 13.92, "end_time": 13.98, "score": 0.01}, {"token": ",", "start_time": 13.98, "end_time": 14.04, "score": 0.0}, {"token": "帮", "start_time": 14.1, "end_time": 14.16, "score": 0.585}, {"token": "我", "start_time": 14.22, "end_time": 14.28, "score": 0.393}, {"token": "联", "start_time": 14.64, "end_time": 14.7, "score": 0.976}, {"token": "系", "start_time": 14.82, "end_time": 14.88, "score": 0.997}, {"token": "一", "start_time": 14.94, "end_time": 15.06, "score": 0.999}, {"token": "下", "start_time": 15.06, "end_time": 15.12, "score": 1.0}, {"token": "那", "start_time": 15.24, "end_time": 15.3, "score": 0.979}, {"token": "个", "start_time": 15.42, "end_time": 15.48, "score": 0.985}, {"token": "车", "start_time": 15.96, "end_time": 16.02, "score": 0.996}, {"token": "主", "start_time": 16.14, "end_time": 16.2, "score": 0.999}, {"token": ",", "start_time": 16.32, "end_time": 16.38, "score": 0.0}, {"token": "好", "start_time": 16.38, "end_time": 16.44, "score": 0.999}, {"token": "吧", "start_time": 16.5, "end_time": 16.56, "score": 0.92}, {"token": ",", "start_time": 16.68, "end_time": 16.74, "score": 0.0}, {"token": "就", "start_time": 16.74, "end_time": 16.8, "score": 0.02}, {"token": "编", "start_time": 17.16, "end_time": 17.22, "score": 0.129}, {"token": "您", "start_time": 19.5, "end_time": 19.56, "score": 0.883}, {"token": "报", "start_time": 19.74, "end_time": 19.8, "score": 0.741}, {"token": "一", "start_time": 19.98, "end_time": 20.04, "score": 0.154}, {"token": "下", "start_time": 20.04, "end_time": 20.1, "score": 0.034}, {"token": "对", "start_time": 20.22, "end_time": 20.28, "score": 0.004}, {"token": "方", "start_time": 20.28, "end_time": 20.34, "score": 0.987}, {"token": "车", "start_time": 20.52, "end_time": 20.58, "score": 0.391}, {"token": "牌", "start_time": 20.7, "end_time": 20.76, "score": 0.803}, {"token": "二", "start_time": 21.48, "end_time": 21.54, "score": 0.861}, {"token": "A", "start_time": 21.78, "end_time": 21.84, "score": 0.0}, {"token": "二", "start_time": 23.34, "end_time": 23.4, "score": 0.743}, {"token": "A", "start_time": 23.64, "end_time": 23.7, "score": 0.0}, {"token": " B", "start_time": 24.54, "end_time": 24.6, "score": 0.0}, {"token": " E", "start_time": 24.84, "end_time": 24.9, "score": 0.0}, {"token": " A", "start_time": 25.14, "end_time": 25.2, "score": 0.0}, {"token": " B", "start_time": 25.32, "end_time": 25.38, "score": 0.0}, {"token": "的", "start_time": 25.5, "end_time": 25.56, "score": 0.986}, {"token": "B", "start_time": 25.62, "end_time": 25.68, "score": 0.0}, {"token": " E", "start_time": 26.7, "end_time": 26.76, "score": 0.0}, {"token": " B", "start_time": 28.86, "end_time": 28.92, "score": 0.0}, {"token": " E", "start_time": 29.1, "end_time": 29.16, "score": 0.0}, {"token": "零", "start_time": 29.94, "end_time": 30.0, "score": 0.943}, {"token": "五", "start_time": 30.24, "end_time": 30.3, "score": 0.988}, {"token": "五", "start_time": 30.48, "end_time": 30.54, "score": 0.988}, {"token": "六", "start_time": 30.66, "end_time": 30.72, "score": 0.224}, {"token": "零", "start_time": 31.98, "end_time": 32.04, "score": 0.917}, {"token": "五", "start_time": 32.28, "end_time": 32.34, "score": 0.993}, {"token": "五", "start_time": 32.64, "end_time": 32.7, "score": 0.986}, {"token": "六", "start_time": 32.88, "end_time": 33.0, "score": 0.983}, {"token": "。", "start_time": 35.52, "end_time": 35.58, "score": 0.0}]}]}

========== 测试时间汇总 ==========
测试开始(北京时间):2026-10-30T18:24:03+08:00
测试结束(北京时间):2026-10-30T18:25:29+08:00
设备:cpu;attention:eager;LLM 精度:fp32
单条音频时长:35.920 秒;测试轮数:2
模型加载耗时:49.930 秒
首轮推理耗时:3.503 秒
全部轮次平均推理耗时:4.943 秒
全部轮次平均 RTF:0.1376
推理累计耗时:9.885 秒
脚本总耗时(main 开始至汇总前):86.798 秒(1.45 分钟)
排除首轮后的平均推理耗时:6.382 秒
排除首轮后的平均 RTF:0.1777
推理计时包含特征提取、模型解码及 generate 内的后处理和 NPU 同步;不含模型加载、WAV 读取和结果打印。脚本总耗时包含环境初始化、加载及结果打印

@LauraGPT 已经提交新的,两个模型都测试过,而且几种环境也都切换验证过,还是很慢

所以想要问一下,是否我安装的包或者代码有问题???同时还想知道哪些模型现在官方到底支不支持,有没有相关的文档

主要語言
Python
星號
21k
分支
2.1k
平均合併
15 小時 16 分鐘
30 天內合併 PR
85

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelscope/FunASR 的其他 Issue

查看 modelscope/FunASR 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。