Skip to content

Commit b95f189

Browse files
committed
add empty cache
1 parent 1cfc5dd commit b95f189

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cosyvoice/cli/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def tts(self, text, flow_embedding, llm_embedding=torch.zeros(0, 192),
209209
self.mel_overlap_dict.pop(this_uuid)
210210
self.hift_cache_dict.pop(this_uuid)
211211
self.flow_cache_dict.pop(this_uuid)
212+
torch.cuda.empty_cache()
212213

213214
def vc(self, source_speech_token, flow_prompt_speech_token, prompt_speech_feat, flow_embedding, stream=False, speed=1.0, **kwargs):
214215
# this_uuid is used to track variables related to this inference thread
@@ -262,6 +263,7 @@ def vc(self, source_speech_token, flow_prompt_speech_token, prompt_speech_feat,
262263
self.llm_end_dict.pop(this_uuid)
263264
self.mel_overlap_dict.pop(this_uuid)
264265
self.hift_cache_dict.pop(this_uuid)
266+
torch.cuda.empty_cache()
265267

266268

267269
class CosyVoice2Model(CosyVoiceModel):
@@ -393,3 +395,4 @@ def tts(self, text, flow_embedding, llm_embedding=torch.zeros(0, 192),
393395
with self.lock:
394396
self.tts_speech_token_dict.pop(this_uuid)
395397
self.llm_end_dict.pop(this_uuid)
398+
torch.cuda.empty_cache()

0 commit comments

Comments
 (0)