Skip to content

[BUG:API] 最新版本代码 v2/tts api 多个请求同时触发时,触发模型推理NAN #238

Open
@EvanJamesMG

Description

@EvanJamesMG

确认清单

  • 我已经阅读过 README.md 和 dependencies.md 文件
  • 我已经确认之前没有 issue 或 discussion 涉及此 BUG
  • 我已经确认问题发生在最新代码或稳定版本中

Forge Commit 或者 Tag

4d8ed07

Python 版本

3.10

PyTorch 版本

'2.4.0+cu121'

操作系统信息

ubuntu

BUG 描述

4个请求同时触发,几乎必现。

BUG 端点

v2/tts

复现参数

  const payload = {
    text,
    spk: { from_spk_name: voice },
    encoder: { format: 'raw' },
    adjust: { speed_rate: 1, normalize: true, headroom: 0.05},
    infer: { stream_chunk_size: 32, no_cache: true, stream: true, seed:42, batch_size:10, spliter_threshold:64},
    tts: { style: 'chat', temperature:0.1, top_p: 0.75,top_k:10}
  };
  const res = await fetch('/api/v2/tts', 

期望结果

正常播放

实际结果

播放异常

错误信息

2025-05-14 05:11:03,614 - modules.api.api_setup - ERROR - Uncaught exception
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/app/modules/core/pipeline/generate/BatchGenerate.py", line 55, in generate
    self.generate_batch_stream(batch)
  File "/app/modules/core/pipeline/generate/BatchGenerate.py", line 98, in generate_batch_stream
    for results in model.generate_batch_stream(
  File "/app/modules/core/models/tts/ChatTtsModel.py", line 166, in _gen
    for results in infer.generate_audio_stream(
  File "/app/modules/core/models/tts/ChatTTS/ChatTTSInfer.py", line 404, in _generator
    for audio_arr in gen:
  File "/home/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    response = gen.send(None)
  File "/app/modules/core/models/tts/ChatTTS/ChatTTSInfer.py", line 152, in _infer
    for result in self.instance._infer_code(
  File "/home/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    response = gen.send(None)
  File "/app/modules/repos_static/ChatTTS/ChatTTS/model/gpt.py", line 598, in generate
    idx_next = torch.multinomial(scores, num_samples=1).to(finish.device)
RuntimeError: probability tensor contains either `inf`, `nan` or element < 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions