diff --git a/python/paddle/fluid/dygraph/base.py b/python/paddle/fluid/dygraph/base.py index 71d5d8b3dc4ecab0c4fed50caa9d37eab87a2cec..15db3169a0451b60908077c08ffed6bc32ef0f10 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(): """