From 064e549bdd54806a80ecb9e40306a853d2a5af13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=99=93=E4=BC=9F?= <39303645+Shixiaowei02@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:15:14 +0800 Subject: [PATCH] force single thread when CINN is on (#44103) --- python/paddle/fluid/compiler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/paddle/fluid/compiler.py b/python/paddle/fluid/compiler.py index 06f206c36d1..38393311de5 100644 --- a/python/paddle/fluid/compiler.py +++ b/python/paddle/fluid/compiler.py @@ -16,6 +16,7 @@ import multiprocessing import os import six import sys +import warnings from .. import compat as cpt from . import framework from .framework import _get_paddle_place, _get_paddle_place_list @@ -373,6 +374,12 @@ class CompiledProgram(object): else: self._exec_strategy.num_threads = len(places) * 2 + if "FLAGS_use_cinn" in core.globals() and core.globals( + )["FLAGS_use_cinn"] and self._exec_strategy.num_threads != 1: + warnings.warn("At present, when CINN is turned on, each process can " \ + "only contain one thread, so reset the number of threads to 1 here.") + self._exec_strategy.num_threads = 1 + if self._build_strategy.num_trainers > 1: assert self._is_data_parallel, \ "If you use multi-trainer to train the model, you should use "\ -- GitLab