From 6dc95b8e0df342db734b596a27fbafc0f59098ff Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Wed, 13 Apr 2022 10:44:16 +0800 Subject: [PATCH] [Eager] Fix multiprocessing eager mode global issue (#41645) (#41690) --- .../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 7825b13001f..3fc06e3c8df 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