#8194 bad allocation:Traceback (most recent call last): File

240e**79a5 Posted at: 58 minutes ago

bad allocation:Traceback (most recent call last):
File "videotrans\process\stt_faster.py", line 139, in faster_whisper
File "faster_whisper\transcribe.py", line 1851, in restore_speech_timestamps
File "faster_whisper\transcribe.py", line 1213, in generate_segments
File "faster_whisper\transcribe.py", line 1446, in generate_with_fallback
MemoryError: bad allocation

Traceback (most recent call last):
File "videotrans\task\only_one.py", line 71, in run
File "videotrans\task\_stage_recogn.py", line 63, in recogn
File "videotrans\recognition\__init__.py", line 141, in run
File "videotrans\recognition\_base.py", line 101, in run
File "videotrans\recognition\_whisper.py", line 39, in _exec
File "videotrans\recognition\_whisper.py", line 137, in _faster
File "videotrans\configure\base.py", line 277, in _new_process
videotrans.configure.excepts.VideoTransError: bad allocation:Traceback (most recent call last):
File "videotrans\process\stt_faster.py", line 139, in faster_whisper
File "faster_whisper\transcribe.py", line 1851, in restore_speech_timestamps
File "faster_whisper\transcribe.py", line 1213, in generate_segments
File "faster_whisper\transcribe.py", line 1446, in generate_with_fallback
MemoryError: bad allocation

trk=[TransCreate]: uuid='6a3575b063', proxy_str=None, cfg=[TaskCfgVTT]当前工作模式: 翻译视频 单视频模式
原始输入文件名: D:/整理文件/无字幕/SNOS-395.mp4,
输出结果保存到文件夹: D:/整理文件/无字幕/_video_out/SNOS-395-mp4,
临时文件夹: D:/win-pyvideotrans-v4.16/tmp/32028/6a3575b063
已选 清理已存在
已启用CUDA加速
未选 降噪
语音识别:faster-whisper(内置), medium, 发音语言: 日语,
翻译渠道:Hy-MT2-1.8B(内置),原始语言:日语,目标语言:简体中文, 已选 发送完整字幕
未选 配音角色,不进行配音
字幕: 嵌入软字幕 , precent=4, hasend=False, should_recogn=True, should_trans=True, should_dubbing=False, should_hebing=True, is_copy_video=False, video_codec_num=264, ignore_align=False, is_audio_trans=False, clone_ref='', should_recogn2=False, do_diarize=True
video_duration_ms=9491850


=
system:Windows-10-10.0.26200-SP0
version:v4.16
frozen:True
language:zh_CN
root_dir:D:/win-pyvideotrans-v4.16

1 Replies

#1 DeepSeek reply at 58 minutes ago

该错误是 "bad allocation"(内存分配失败) 引起的,发生在 faster-whisper(medium 模型)语音识别阶段。核心原因是运行模型时 系统物理内存或显卡显存不足,导致底层 C++ 无法继续分配内存。

你当前识别的视频时长约 2.6 小时(9491850ms),在启用 CUDA 加速、使用 medium 模型、未降噪的情况下,内存/显存消耗会成倍增加,极易触发 MemoryError。

解决方案

  1. 降低模型尺寸
    将语音识别模型从 medium 改为 small 或 base,可大幅减少内存/显存占用。若仍失败可继续降到 tiny。
  2. 关闭CUDA加速
    在任务尚未开始时可取消勾选 启用CUDA加速,用纯CPU模式运行(速度会慢,但内存分配失败几率降低)。
  3. 调整计算数据精度
    进入 菜单 -> 工具/选项 -> 高级选项 -> 语音识别参数:

    • 将 计算数据类型 改为 int8(最省显存);
    • 将 识别准确度beam_size 和 best_of 都改为 1;
    • 关闭 启用上下文感知。
  4. 释放系统内存/显存

    • 关闭其他占用内存的软件;
    • 使用 nvidia-smi 查看 GPU 是否有足够空闲显存;
    • 若系统物理内存不足,可增加 Windows 虚拟内存。
  5. 长视频拆分成多个短视频处理
    2.6 小时的视频会累积大量中间数据,建议先用剪辑工具分割为 20~30 分钟的片段,再逐个翻译。
  6. 如果继续使用CUDA
    请确认已正确安装 CUDA 12.8+ 和 cuDNN 9.11+,并更新 NVIDIA 驱动到最新。若配置正确但显存仍不足,请参考上方第1~3点降低负载。

若以上步骤仍无法解决,请将软件根目录 logs/ 文件夹下最新的日志文件底部约30行信息提供出来,以便进一步分析。

请查阅相关文档:

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