From b95f18909ed42cdea1b81f361695e0dcb1126b7c Mon Sep 17 00:00:00 2001 From: "lyuxiang.lx" Date: Fri, 10 Jan 2025 14:14:32 +0800 Subject: [PATCH] add empty cache --- cosyvoice/cli/model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cosyvoice/cli/model.py b/cosyvoice/cli/model.py index ea24723..20de439 100644 --- a/cosyvoice/cli/model.py +++ b/cosyvoice/cli/model.py @@ -209,6 +209,7 @@ class CosyVoiceModel: self.mel_overlap_dict.pop(this_uuid) self.hift_cache_dict.pop(this_uuid) self.flow_cache_dict.pop(this_uuid) + torch.cuda.empty_cache() def vc(self, source_speech_token, flow_prompt_speech_token, prompt_speech_feat, flow_embedding, stream=False, speed=1.0, **kwargs): # this_uuid is used to track variables related to this inference thread @@ -262,6 +263,7 @@ class CosyVoiceModel: self.llm_end_dict.pop(this_uuid) self.mel_overlap_dict.pop(this_uuid) self.hift_cache_dict.pop(this_uuid) + torch.cuda.empty_cache() class CosyVoice2Model(CosyVoiceModel): @@ -393,3 +395,4 @@ class CosyVoice2Model(CosyVoiceModel): with self.lock: self.tts_speech_token_dict.pop(this_uuid) self.llm_end_dict.pop(this_uuid) + torch.cuda.empty_cache()