Skip to content

Commit 392ae69

Browse files
authored
Set parallel executor thread num under nccl2 distributed env (#13207)
1 parent 620392e commit 392ae69

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/paddle/fluid/parallel_executor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ def __init__(self,
128128
os.environ.get('CPU_NUM', multiprocessing.cpu_count()))
129129
exec_strategy.num_threads = cpu_num * 2
130130

131+
# Set 1 thread num under nccl2 distribute
132+
# env to make sure all gpus run ops in same order.
133+
if num_trainers > 1:
134+
assert (use_cuda)
135+
# FIXME(gongwb): avoid this set.
136+
exec_strategy.num_threads = 1
137+
131138
if build_strategy is None:
132139
build_strategy = BuildStrategy()
133140

0 commit comments

Comments
 (0)