Fix ChatTTS CUDA device-side assert with text sanitize and GPU recovery.

Re-enable KV cache by default, normalize digits and unsafe chars, disable per-chunk split_text, and reload ChatTTS after CUDA errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-12 17:13:57 +08:00
parent 1779449bba
commit 8be34a2fd5
4 changed files with 128 additions and 10 deletions
+19
View File
@@ -15,6 +15,10 @@ def release_cuda_cache() -> None:
import torch
if torch.cuda.is_available():
try:
torch.cuda.synchronize()
except Exception:
pass
torch.cuda.empty_cache()
if hasattr(torch.cuda, "ipc_collect"):
torch.cuda.ipc_collect()
@@ -22,6 +26,21 @@ def release_cuda_cache() -> None:
pass
def is_cuda_runtime_error(exc: BaseException) -> bool:
msg = str(exc).lower()
return any(
k in msg
for k in (
"cuda error",
"device-side assert",
"out of memory",
"cublas",
"illegal memory access",
"an illegal instruction",
)
)
def cuda_memory_summary() -> str:
"""返回简要显存占用(调试用)。"""
try: