diff --git a/python/paddle/fluid/compiler.py b/python/paddle/fluid/compiler.py index 1e6714479d4a6ec3d08acec2c52a857a8cf986cc..7e0ef8d150d2102874a9bbea79c177c49b3ebad7 100644 --- a/python/paddle/fluid/compiler.py +++ b/python/paddle/fluid/compiler.py @@ -101,6 +101,10 @@ class CompiledProgram(object): self._exec_strategy = exec_strategy self._loss_name = loss_name self._share_vars_from = share_vars_from + if self._exec_strategy is None: + self._exec_strategy = ExecutionStrategy() + if self._build_strategy is None: + self._build_strategy = BuildStrategy() return self def _with_distributed(self): @@ -124,12 +128,6 @@ class CompiledProgram(object): else: self._local_scopes = [] - self._places = [] - if self._exec_strategy is None: - self._exec_strategy = ExecutionStrategy() - if self._build_strategy is None: - self._build_strategy = BuildStrategy() - self._exec_strategy.use_cuda = isinstance(self._place, core.CUDAPlace) if self._exec_strategy.use_cuda: gpus_env = os.getenv("FLAGS_selected_gpus") @@ -194,6 +192,7 @@ class CompiledProgram(object): if place and self._place != place: raise ValueError("Cannot compile with different place") return self + self._compiled = True self._scope = scope self._place = place