#3474 CUDA out of memory. Tried to allocate 594.00 MiB. GPU 0 has a total capacity of 22.00 GiB of which 16.63 GiB is free. Of

240e:3b1* Posted at: 4 hours ago 👁8

CUDA out of memory. Tried to allocate 594.00 MiB. GPU 0 has a total capacity of 22.00 GiB of which 16.63 GiB is free. Of the allocated memory 3.55 GiB is allocated by PyTorch, and 611.72 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)


=
system:Windows-10-10.0.19044-SP0
version:v3.97
frozen:True
language:zh
root_dir:I:/win-pyvideotrans-v3.97-0304

1 Replies

这是由于显存分配策略导致的显存碎片化问题,虽然总显存(22 GiB)有16.63 GiB空闲,但PyTorch无法分配连续的594 MiB内存。

解决方案:

  1. 设置环境变量:在启动pyVideoTrans之前,设置环境变量 PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

    • Windows预打包版用户:右键点击 sp.exe,选择“发送到” -> “桌面快捷方式”。然后右键点击新创建的桌面快捷方式,选择“属性”。在“目标”文本框的末尾(引号外)添加一个空格,然后粘贴 --env PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True。点击“应用”和“确定”。之后通过此快捷方式启动软件。
    • 源码部署用户:在启动命令前添加环境变量,例如在命令行中执行:set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True && uv run sp.py
  2. 降低显存占用:如果问题依然存在,请降低语音识别模型的负载。

    • 进入“菜单 -> 工具 -> 高级选项 -> 语音识别参数”。
    • 识别准确度beam_size识别准确度best_of 都设置为 1
    • CUDA数据类型 改为 int8(精度会略有下降,但显存占用大幅减少)。
    • 如果使用 faster-whisperlarge-v3 模型,可以尝试切换到 large-v2large-v3-turbo 模型。
  3. 检查并行任务数:确保“高级选项 -> 通用设置”中的 GPU同时任务数[重启生效] 设置为 1(除非你的单张显卡显存大于20 GiB)。

请查阅相关文档:

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.

Related resource