From d5c818131bfee99c01c0b6cf7888a0bd6aceefca Mon Sep 17 00:00:00 2001
From: 嘉渊 <wangjiaming.wjm@alibaba-inc.com>
Date: 星期四, 27 七月 2023 15:24:14 +0800
Subject: [PATCH] update

---
 funasr/bin/build_trainer.py |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/funasr/bin/build_trainer.py b/funasr/bin/build_trainer.py
index 7979d25..dc295d8 100644
--- a/funasr/bin/build_trainer.py
+++ b/funasr/bin/build_trainer.py
@@ -532,11 +532,9 @@
     args = build_args(args, parser, extra_task_params)
 
     if args.local_rank is not None:
-        args.distributed = True
-        args.simple_ddp = True
+        distributed = True
     else:
-        args.distributed = False
-        args.ngpu = 1
+        distributed = False
     args.local_rank = args.local_rank if args.local_rank is not None else 0
     local_rank = args.local_rank
     if "CUDA_VISIBLE_DEVICES" in os.environ.keys():
@@ -593,6 +591,12 @@
     args.batch_type = "length"
     args.oss_bucket = None
     args.input_size = None
+    if distributed:
+        args.distributed = True
+        args.simple_ddp = True
+    else:
+        args.distributed = False
+        args.ngpu = 1
     if optim is not None:
         args.optim = optim
     if lr is not None:
@@ -627,8 +631,6 @@
     torch.backends.cudnn.deterministic = args.cudnn_deterministic
 
     # ddp init
-    os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_id)
-    args.distributed = args.ngpu > 1 or args.dist_world_size > 1
     distributed_option = build_distributed(args)
 
     # for logging

--
Gitblit v1.9.1