#8374 语音识别阶段出错:无效的值或参数: Expected parameter logits (Tensor of shape (1, 51866)) of distribution Categorical(logits: torch.Size(

106.61**7 Posted at: 2 hours ago

语音识别阶段出错:无效的值或参数: 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')[openai-whisper(本地)]:
Traceback (most recent call last):
File "videotrans\task\job.py", line 97, in run
File "videotrans\task\_speech2text.py", line 93, in recogn
File "videotrans\recognition\__init__.py", line 204, in run
File "videotrans\recognition\_base.py", line 70, in run
File "videotrans\recognition\_openai.py", line 71, in _exec
File "whisper\transcribe.py", line 295, in transcribe

result: DecodingResult = decode_with_fallback(mel_segment)

File "whisper\transcribe.py", line 201, in decode_with_fallback

decode_result = model.decode(segment, options)

File "torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 824, in decode

result = DecodingTask(model, options).run(mel)

File "torch\utils\_contextlib.py", line 116, in decorate_context

return func(*args, **kwargs)

File "whisper\decoding.py", line 737, in run

tokens, sum_logprobs, no_speech_probs = self._main_loop(audio_features, tokens)

File "whisper\decoding.py", line 703, in _main_loop

tokens, completed = self.decoder.update(tokens, logits, sum_logprobs)

File "whisper\decoding.py", line 283, in update

next_tokens = Categorical(logits=logits / self.temperature).sample()

File "torch\distributions\categorical.py", line 73, in init

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

File "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')


=
Windows-10-10.0.26100-SP0
version:v3.80
frozen:True
language:zh

1 Replies

#1 DeepSeek reply at 2 hours ago

这是模型推理过程中 logits 输出 NaN(数值溢出/异常),通常由 CUDA/cuDNN 版本不匹配、显卡 fp16 计算不兼容、或显存异常导致,而非字幕或视频文件本身的问题。

解决方案(按顺序尝试):

  1. 先改用默认的 faster-whisper(内置) 渠道,模型选 large-v3-turbo 或 medium,它对本类数值问题的兼容性更好:

    • 主界面「语音识别」下拉改选 faster-whisper(内置)
  2. 调低计算精度要求:菜单 → 工具 → 高级选项 → 语音识别参数

    • 将 计算数据类型 改为 float32(最稳,最慢)或 int8(最省显存)
    • 将 识别准确度beam_size 和 识别准确度best_of 都调为 1
    • 取消勾选 启用上下文感知
  3. 检查 GPU 环境(openai-whisper 需要正确的 CUDA 运行时):

    • 要求 CUDA Toolkit ≥ 12.8、cuDNN ≥ 9.11,且 CUDA 的 bin、lib 目录已加入系统环境变量 Path
    • CMD 中执行 nvcc -V 和 nvidia-smi 核对版本
  4. 降低显存压力:换小模型(medium/small),或直接取消勾选 启用CUDA加速 用纯 CPU 跑一次,若 CPU 正常而 GPU 报 NaN,基本可锁定为 CUDA/驱动兼容问题。
  5. 强烈建议升级版本:你当前是 v3.80,属于很旧的版本,新版对 whisper 推理、模型下载、异常重试均做了大量修复。请下载最新完整包(约 2.7GB)解压使用,仅覆盖补丁包易出错。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
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