From 8666902b9d2c9ae79daca93802b4fab974d27ced Mon Sep 17 00:00:00 2001 From: Wu Yi Date: Mon, 18 Feb 2019 09:37:56 +0800 Subject: [PATCH] fix test_transpiler random fail test=develop (#15736) --- .../fluid/tests/unittests/test_dist_transpiler.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_dist_transpiler.py b/python/paddle/fluid/tests/unittests/test_dist_transpiler.py index 3566fed21..12132477d 100644 --- a/python/paddle/fluid/tests/unittests/test_dist_transpiler.py +++ b/python/paddle/fluid/tests/unittests/test_dist_transpiler.py @@ -22,6 +22,9 @@ import six import unittest import numpy as np +import gc +gc.set_debug(gc.DEBUG_COLLECTABLE) + import paddle.fluid as fluid @@ -99,6 +102,12 @@ class TranspilerTest(unittest.TestCase): with fluid.unique_name.guard(): with fluid.program_guard(main, startup): self.transpiler_test_impl() + # NOTE: run gc.collect to eliminate pybind side objects to + # prevent random double-deallocate when inherited in python. + del self.transpiler + del main + del startup + gc.collect() class TestBasicModel(TranspilerTest): @@ -797,6 +806,7 @@ class TestNCCL2Transpile(TranspilerTest): print([op.type for op in startup.global_block().ops]) self.assertEqual(startup.global_block().ops[-1].type, "gen_nccl_id") self.assertIsNotNone(startup.global_block().vars.get("NCCLID")) + gc.collect() else: pass -- GitLab