From b01b84ae47a5f80e9acded9412fc8229ca561943 Mon Sep 17 00:00:00 2001 From: x54-729 <17307130121@fudan.edu.cn> Date: Tue, 20 Sep 2022 14:53:26 +0800 Subject: [PATCH] =?UTF-8?q?ddp=20barrier=20=E6=B7=BB=E5=8A=A0=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=B7=B2=E5=88=9D=E5=A7=8B=E5=8C=96=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/core/drivers/torch_driver/ddp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastNLP/core/drivers/torch_driver/ddp.py b/fastNLP/core/drivers/torch_driver/ddp.py index 9330b9fc..924595c2 100644 --- a/fastNLP/core/drivers/torch_driver/ddp.py +++ b/fastNLP/core/drivers/torch_driver/ddp.py @@ -661,7 +661,7 @@ class TorchDDPDriver(TorchDriver): r""" 通过使用该函数来使得各个进程之间同步操作。 """ - if int(os.environ.get(FASTNLP_NO_SYNC, 0)) < 1: # 当 FASTNLP_NO_SYNC 小于 1 时实际执行 + if int(os.environ.get(FASTNLP_NO_SYNC, 0)) < 1 and dist.is_initialized(): # 当 FASTNLP_NO_SYNC 小于 1 时实际执行 torch.distributed.barrier(async_op=False) def is_distributed(self):