From 5f65d9d58c9e191099f5bb96ce331b14f65b27b9 Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Fri, 8 May 2020 19:25:31 +0800 Subject: [PATCH] Fix dygraph exit issue (#24347) * 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 f4faf35f9a4..fd20001a6e4 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 @@ -134,6 +135,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