#6740 语音识别阶段出错[openai-whisper(内置)] Expected parameter logits (Tensor of shape (1, 51866)) of distribution Categorical(logits:

106.61.**9 Posted at: 2 hours ago

语音识别阶段出错[openai-whisper(内置)] Expected parameter logits (Tensor of shape (1, 51866)) of distribution Categorical(logits: torch.Size([1, 51866])) to satisfy the constraint IndependentConstraint(Real(), 1), but found invalid values:
tensor([[nan, nan, nan, ..., nan, nan, nan]], device='cuda:0'):Traceback (most recent call last):
File "videotrans\process\stt_openai.py", line 104, in openai_whisper
File "whisper\transcribe.py", line 295, in transcribe
File "whisper\transcribe.py", line 201, in decode_with_fallback
File "D:\win-pyvideotrans-v4.10\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 824, in decode
File "D:\win-pyvideotrans-v4.10\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 737, in run
File "whisper\decoding.py", line 703, in _main_loop
File "whisper\decoding.py", line 283, in
......
eter logits (Tensor of shape (1, 51866)) of distribution Categorical(logits: torch.Size([1, 51866])) to satisfy the constraint IndependentConstraint(Real(), 1), but found invalid values:
tensor([[nan, nan, nan, ..., nan, nan, nan]], device='cuda:0'):Traceback (most recent call last):
File "videotrans\process\stt_openai.py", line 104, in openai_whisper
File "whisper\transcribe.py", line 295, in transcribe
File "whisper\transcribe.py", line 201, in decode_with_fallback
File "D:\win-pyvideotrans-v4.10\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 824, in decode
File "D:\win-pyvideotrans-v4.10\_internal\torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 737, in run
File "whisper\decoding.py", line 703, in _main_loop
File "whisper\decoding.py", line 283, in update
File "D:\win-pyvideotrans-v4.10\_internal\torch\distributions\categorical.py", line 73, in init

super().__init__(batch_shape, validate_args=validate_args)

File "D:\win-pyvideotrans-v4.10\_internal\torch\distributions\distribution.py", line 72, in init

raise ValueError(

ValueError: Expected parameter logits (Tensor of shape (1, 51866)) of distribution Categorical(logits: torch.Size([1, 51866])) to satisfy the constraint IndependentConstraint(Real(), 1), but found invalid values:
tensor([[nan, nan, nan, ..., nan, nan, nan]], device='cuda:0')
[SpeechToText]语音转录: self.out_format='srt',self.copysrt_rawvideo=False,self.spk_insert=True
[TaskCfgSTT]
原始输入文件名: E:/DownLoad/DCL/5tHt9pEx6.mp4,
输出结果保存到文件夹: D:/win-pyvideotrans-v4.10/output/recogn,
临时文件夹: D:/win-pyvideotrans-v4.10/tmp/8612/bb09353d7d
已启用CUDA加速
未选 降噪
语音识别:openai-whisper(内置), large-v3-turbo 断句方式:默认断句
发音语言:自动检测
未选 降噪


=
system:Windows-10-10.0.26100-SP0
version:v4.10
frozen:True
language:zh
root_dir:D:/win-pyvideotrans-v4.10

1 Replies

#1 DeepSeek reply at 2 hours ago

这个报错说明 openai-whisper 在进行语音识别时,模型内部计算出现 NaN(无效值),常见原因是 CUDA 环境不稳定或显存不足。

建议按以下步骤排查:

  1. 先关闭“已启用CUDA加速”,改用 CPU 模式重新识别一次。如果 CPU 模式正常,则基本可确定是 NVIDIA 显卡 CUDA 加速环节的问题。
  2. 如果必须使用 GPU,请检查:

    • 显存是否充足(large-v3-turbo 至少需要 6GB 可用显存,若显存小请换用 medium/small 模型)。
    • 显卡驱动是否为最新版,并确认已正确安装 CUDA 12.8+ 与 cuDNN 9.x,且相关 bin/lib 已加入系统环境变量。
  3. 在「高级选项 → 语音识别参数」中,将「计算数据类型」改为 float16 或 int8,并把 beam_size/best_of 调低(如设为 1),关闭「启用上下文感知」,降低显存压力。
  4. 若仍出现同样错误,可能是模型文件下载不完整或损坏。删除软件目录下 models/ 中对应的 openai-whisper 模型文件(.pt 文件)后重新下载,或参考官方文档手动下载模型文件放到 models/ 目录。
  5. 如果以上都不行,请改用 faster-whisper(内置) 渠道,其稳定性和兼容性通常更好。

请查阅相关文档:

Thinking...
Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource