From ff6c04069027fad18386ecd9118f3f32c4f9812f Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Fri, 5 Jun 2020 10:58:23 +0800 Subject: [PATCH] Fix dygraph exit issue (#24347) (#24838) * add clean up; test=develop * add import; test=develop --- python/paddle/fluid/dygraph/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/paddle/fluid/dygraph/base.py b/python/paddle/fluid/dygraph/base.py index 71d5d8b3dc4..15db3169a04 100644 --- a/python/paddle/fluid/dygraph/base.py +++ b/python/paddle/fluid/dygraph/base.py @@ -19,6 +19,7 @@ import sys import numpy as np from paddle.fluid import core from paddle.fluid import framework +from paddle.fluid.multiprocess_utils import CleanupFuncRegistrar from .tracer import Tracer import logging import objgraph @@ -182,6 +183,9 @@ def enable_dygraph(place=None): _functional_dygraph_context_manager = guard(place=place) _functional_dygraph_context_manager.__enter__() + # call disable_dygraph when Python exit + CleanupFuncRegistrar.register(disable_dygraph) + def disable_dygraph(): """ -- GitLab