From 582cc297996ccb1e2a28bacc93092158cb5b06a1 Mon Sep 17 00:00:00 2001 From: chengduo Date: Fri, 26 Jul 2019 20:39:15 -0500 Subject: [PATCH] add warning info for CPU_NUM (#18840) test=develop --- python/paddle/fluid/framework.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 9371406ddb6..0bf0e7c3e91 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -85,11 +85,14 @@ def _current_expected_place(): def _cpu_num(): if "CPU_NUM" not in os.environ.keys(): - sys.stderr.write( - 'The CPU_NUM is not specified, you should set CPU_NUM in ' - 'the environment variable list, i.e export CPU_NUM=1. CPU_NUM ' - 'indicates that how many CPUPlace are used in the current task.\n' - '!!! The default number of CPUPlaces is 1.\n\n') + if multiprocessing.cpu_count() > 1: + sys.stderr.write( + '!!! The CPU_NUM is not specified, you should set CPU_NUM in the environment variable list.\n' + 'CPU_NUM indicates that how many CPUPlace are used in the current task.\n' + 'And if this parameter are set as N (equal to the number of physical CPU core) the program may be faster.\n\n' + 'export CPU_NUM={} # for example, set CPU_NUM as number of physical CPU core which is {}.\n\n' + '!!! The default number of CPU_NUM=1.\n'.format( + multiprocessing.cpu_count(), multiprocessing.cpu_count())) os.environ['CPU_NUM'] = str(1) cpu_num = os.environ.get('CPU_NUM') return int(cpu_num) -- GitLab