From 606848af4a9062209179b5424a34fc310fd85884 Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Tue, 12 Apr 2022 13:25:39 +0800 Subject: [PATCH] [Eager] Fix multiprocessing eager mode global issue (#41645) --- .../fluid/tests/unittests/test_paddle_multiprocessing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/tests/unittests/test_paddle_multiprocessing.py b/python/paddle/fluid/tests/unittests/test_paddle_multiprocessing.py index 7825b13001..3fc06e3c8d 100644 --- a/python/paddle/fluid/tests/unittests/test_paddle_multiprocessing.py +++ b/python/paddle/fluid/tests/unittests/test_paddle_multiprocessing.py @@ -19,13 +19,16 @@ import unittest import time import paddle import paddle.incubate.multiprocessing as mp -from paddle.fluid.framework import _test_eager_guard, _in_legacy_dygraph, in_dygraph_mode +from paddle.fluid.framework import _test_eager_guard, _in_legacy_dygraph, in_dygraph_mode, _enable_legacy_dygraph REPEAT = 20 HAS_SHM_FILES = os.path.isdir('/dev/shm') def fill_tensor(queue, event): + # make sure run in legacy dygraph + if in_dygraph_mode(): + _enable_legacy_dygraph() data = queue.get() with paddle.no_grad(): data[0][:] = 5 -- GitLab