#3110 启动自定义音色-1.7B模型.bat 没有 * To create a public link, set `share=True` in `launch()`.

188.253* Posted at: 11 hours ago 👁16

按照帮助开启GPU
runtime\python -m pip install --force-reinstall torch torchaudio --index-url https://download.pytorch.org/whl/cu128
runtime\python -m pip install flash-attn --no-build-isolation
并且删掉自定义音色-1.7B模型.bat文件末尾的 --no-flash-attn --device cpu --dtype float32 代码,重启后
【当前启动的是:自定义音色 1.7B 模型 Qwen3-TTS-12Hz-1.7B-CustomVoice】

可使用这些音色 Vivian,Serena,Uncle_fu,Dylan,Eric,Ryan,Aiden,Ono_anna,Sohee

启动成功后,请在浏览器中打开: http://127.0.0.1:8000
第一次启动后需要下载模型,请耐心等待...

    *******************************
    如果你在 pyVideoTrans 中使用,请将该地址填写在菜单-TTS设置-Qwen3 TTS(本地)的WebUI URL中

    在该设置中测试时,请删掉填写的参考音频,自定义音色模型不可使用参考音频测试,否则会出错
    *******************************

    如果配置环境和下载模型中出错,请尝试科学上网,然后右键本bat文件-编辑-删掉该文件顶部第5行如下内容

            set HF_ENDPOINT=https://hf-mirror.com

    如果你有英伟达显卡并配置了CUDA环境,想加快语音合成速度,也请在本bat文件,删掉最后一行代码中的如下内容

            --device cpu --dtype float32

    然后保存关闭重新运行
    *******************************

    运行中可能出现一些"Warning:"或"SoX could not"信息,忽略即可, 当显示如下信息时即为启动成功:

    * To create a public link, set `share=True` in `launch()`.

Warning: flash-attn is not installed. Will only run the manual PyTorch version. Please install flash-attn for faster inference.


'sox' is not recognized as an internal or external command,
operable program or batch file.
SoX could not be found!

If you do not have SoX, proceed here:
 - - - http://sox.sourceforge.net/ - - -

If you do (or think that you should) have SoX, double-check your
path variables.

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\qwen_tts\cli\demo.py", line 634, in

raise SystemExit(main())
                 ^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\qwen_tts\cli\demo.py", line 608, in main

tts = Qwen3TTSModel.from_pretrained(
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\qwen_tts\inference\qwen3_tts_model.py", line 112, in from_pretrained

model = AutoModel.from_pretrained(pretrained_model_name_or_path, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\models\auto\auto_factory.py", line 604, in from_pretrained

return model_class.from_pretrained(
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\qwen_tts\core\models\modeling_qwen3_tts.py", line 1876, in from_pretrained

model = super().from_pretrained(
        ^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 277, in _wrapper

return func(*args, **kwargs)
       ^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 4971, in from_pretrained

model = cls(config, *model_args, **model_kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\qwen_tts\core\models\modeling_qwen3_tts.py", line 1817, in init

super().__init__(config)

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 2076, in init

self.config._attn_implementation_internal = self._check_and_adjust_attn_implementation(
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 2686, in _check_and_adjust_attn_implementation

applicable_attn_implementation = self.get_correct_attn_implementation(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 2714, in get_correct_attn_implementation

self._flash_attn_2_can_dispatch(is_init_check)

File "D:\aimodels\qwen3tts-win-0124-new\runtime\Lib\site-packages\transformers\modeling_utils.py", line 2422, in _flash_attn_2_can_dispatch

raise ImportError(f"{preface} the package flash_attn seems to be not installed. {install_message}")

ImportError: FlashAttention2 has been toggled on, but it cannot be used due to the following error: the package flash_attn seems to be not installed. Please refer to the documentation of https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-2 to install Flash Attention 2.
Press any key to continue . . .

http://127.0.0.1:8000打不开。该怎么办?

7 Replies

这是因为 FlashAttention2 依赖包 flash-attn 安装失败或未正确安装,导致 Qwen3-TTS 自定义音色模型无法启动。

  1. 重新安装 flash-attn

    • 确保已按照帮助文档执行了 runtime\python -m pip install flash-attn --no-build-isolation
    • 如果上述命令失败,请尝试使用 runtime\python -m pip install flash-attn --no-build-isolation --no-cache-dir 重新安装。
    • 如果仍失败,可能需要先安装 Visual Studio C++ 构建工具。请访问 安装 Visual Studio Community 免费版 获取安装指南。
  2. 临时解决方案(强制使用 CPU 模式)

    • 如果显卡或 CUDA 环境有问题,可以暂时回退到 CPU 模式运行。
    • 编辑 自定义音色-1.7B模型.bat 文件,在最后一行命令的末尾重新添加 --device cpu --dtype float32 参数,然后保存并重新运行该批处理文件。
  3. 检查网络与模型下载

请查阅相关文档:

重新安装返回错误
ERROR: Failed building wheel for flash-attn

这是因为系统缺少编译 flash-attn 所需的 C++ 构建环境。

  1. 安装 Visual Studio Build Tools:这是编译 flash-attn 等 CUDA 扩展的必要组件。

    • 访问 Visual Studio 下载页面
    • 下载并安装 Visual Studio Community 2022
    • 在安装程序中,务必勾选 “使用 C++ 的桌面开发” 工作负载,并在右侧的“可选”组件中确保 “Windows 10/11 SDK” 被选中。然后进行安装。
  2. 使用预编译的 wheel 包:如果不想或无法安装完整的 Visual Studio,可以尝试寻找与你的 Python 版本、CUDA 版本和系统匹配的预编译 flash-attn wheel 文件。

    • 访问 flash-attn 的 GitHub Releases 页面 或通过其他渠道(如第三方镜像)查找预编译包。
    • 下载对应的 .whl 文件后,使用命令 runtime\python -m pip install <下载的whl文件路径> 进行安装。
  3. 临时回退方案:如果以上方法都困难,可以暂时禁用 flash-attn,让模型使用标准的 PyTorch 注意力机制运行。

    • 编辑 自定义音色-1.7B模型.bat 文件。
    • 在最后一行启动命令中,重新添加 --no-flash-attn 参数。
    • 保存文件并重新运行。这样模型将不使用 FlashAttention2,可以正常启动,但推理速度会稍慢。

请查阅相关文档:

image
有很多下载哪个?

根据你的截图,你需要安装 Visual Studio Community 2022。在安装程序的工作负载列表中,请勾选 “使用 C++ 的桌面开发”。安装完成后,重新尝试运行 runtime\python -m pip install flash-attn --no-build-isolation 命令。

可以右键编辑你打开的这个bat文件,在最后倒数第二行命令后加上 --no-flash-attn ,注意前面要有空格,然后保存,重启运行这个bat

根据你的描述,你已经找到了解决方案。请按照以下步骤操作:

  1. 右键点击 自定义音色-1.7B模型.bat 文件,选择“编辑”。
  2. 在文件最后倒数第二行命令的末尾,添加一个空格,然后加上 --no-flash-attn 参数。
  3. 保存文件并关闭编辑器。
  4. 双击运行修改后的 自定义音色-1.7B模型.bat 文件。

这个操作会禁用 FlashAttention2,让 Qwen3-TTS 模型使用标准的 PyTorch 注意力机制运行,从而绕过 flash-attn 编译失败的问题。模型可以正常启动,但合成速度会比启用 GPU 加速时稍慢。

请查阅相关文档:

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