Skip to content

Commit 6dc95b8

Browse files
authored
[Eager] Fix multiprocessing eager mode global issue (#41645) (#41690)
1 parent acb1382 commit 6dc95b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/paddle/fluid/tests/unittests/test_paddle_multiprocessing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
import time
2020
import paddle
2121
import paddle.incubate.multiprocessing as mp
22-
from paddle.fluid.framework import _test_eager_guard, _in_legacy_dygraph, in_dygraph_mode
22+
from paddle.fluid.framework import _test_eager_guard, _in_legacy_dygraph, in_dygraph_mode, _enable_legacy_dygraph
2323

2424
REPEAT = 20
2525
HAS_SHM_FILES = os.path.isdir('/dev/shm')
2626

2727

2828
def fill_tensor(queue, event):
29+
# make sure run in legacy dygraph
30+
if in_dygraph_mode():
31+
_enable_legacy_dygraph()
2932
data = queue.get()
3033
with paddle.no_grad():
3134
data[0][:] = 5

0 commit comments

Comments
 (0)