From 153ccde9bb25d1baaa420f89791201080b140c9b Mon Sep 17 00:00:00 2001 From: asamaayako <52999091+asamaayako@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:35:30 +0800 Subject: [PATCH] fix: Windows not yet supported for torch.compile (#377) --- ChatTTS/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChatTTS/core.py b/ChatTTS/core.py index 9a00a4cc0..e22b2ae80 100644 --- a/ChatTTS/core.py +++ b/ChatTTS/core.py @@ -122,7 +122,10 @@ def _load( assert gpt_ckpt_path, 'gpt_ckpt_path should not be None' gpt.load_state_dict(torch.load(gpt_ckpt_path)) if compile and 'cuda' in str(device): - gpt.gpt.forward = torch.compile(gpt.gpt.forward, backend='inductor', dynamic=True) + try: + gpt.gpt.forward = torch.compile(gpt.gpt.forward, backend='inductor', dynamic=True) + except RuntimeError as e: + logging.warning(f'Compile failed,{e}. fallback to normal mode.') self.pretrain_models['gpt'] = gpt spk_stat_path = os.path.join(os.path.dirname(gpt_ckpt_path), 'spk_stat.pt') assert os.path.exists(spk_stat_path), f'Missing spk_stat.pt: {spk_stat_path}'