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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user