From e8a26827ae3accf33a3aecd9b88b2514bd724a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E6=81=AF?= Date: Wed, 16 Apr 2025 16:04:40 +0800 Subject: [PATCH] Refactor CUDA stream context management in CosyVoice2Model - Replaced the use of torch.cuda.stream with a direct context management approach for improved clarity and performance during inference. - This change simplifies the stream handling code while maintaining efficient resource utilization. --- cosyvoice/cli/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cosyvoice/cli/model.py b/cosyvoice/cli/model.py index d72816a..8e1b21e 100644 --- a/cosyvoice/cli/model.py +++ b/cosyvoice/cli/model.py @@ -385,7 +385,7 @@ class CosyVoice2Model(CosyVoiceModel): # this_uuid is used to track variables related to this inference thread self.synchronize_stream() stream_context = self.stream_context_pool.get() - with torch.cuda.stream(stream_context): + with stream_context: this_uuid = str(uuid.uuid1()) with self.lock: