From 0270f62addd6ea7f6141584e2782c6cd751ce1fd Mon Sep 17 00:00:00 2001
From: haoneng.lhn <haoneng.lhn@alibaba-inc.com>
Date: 星期三, 02 八月 2023 10:50:23 +0800
Subject: [PATCH] fix uniasr finetune bug

---
 funasr/bin/asr_inference_launch.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/funasr/bin/asr_inference_launch.py b/funasr/bin/asr_inference_launch.py
index 701379a..dda2879 100644
--- a/funasr/bin/asr_inference_launch.py
+++ b/funasr/bin/asr_inference_launch.py
@@ -260,8 +260,6 @@
         hotword_list_or_file = None
         clas_scale = 1.0
 
-    if kwargs.get("device", None) == "cpu":
-        ngpu = 0
     if ngpu >= 1 and torch.cuda.is_available():
         device = "cuda"
     else:
@@ -439,6 +437,7 @@
         logging.info(rtf_avg)
         if writer is not None:
             ibest_writer["rtf"]["rtf_avf"] = rtf_avg
+        torch.cuda.empty_cache()
         return asr_result_list
 
     return _forward
@@ -730,6 +729,7 @@
                     ibest_writer["time_stamp"][key] = "{}".format(time_stamp_postprocessed)
 
             logging.info("decoding, utt: {}, predictions: {}".format(key, text_postprocessed_punc))
+        torch.cuda.empty_cache()
         return asr_result_list
 
     return _forward

--
Gitblit v1.9.1