fix: Windows not yet supported for torch.compile (#377)

This commit is contained in:
asamaayako
2024-06-20 21:35:30 +08:00
committed by GitHub
parent 654b0f291b
commit 153ccde9bb
+4 -1
View File
@@ -122,7 +122,10 @@ class Chat:
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}'