diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index d744394022f8c40d7d5956ccc6d9f8274141985c..bdb9bc7e267a79e7395489a4e6e6f9eac8bbd028 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -86,6 +86,14 @@ bool IsCompiledWithCUDA() { #endif } +bool IsCompiledWithMKLDNN() { +#ifndef PADDLE_WITH_MKLDNN + return false; +#else + return true; +#endif +} + bool IsCompiledWithBrpc() { #ifndef PADDLE_WITH_DISTRIBUTE return false; @@ -873,6 +881,7 @@ All parameter, weight, gradient are variables in Paddle. [](bool init_p2p) { framework::InitDevices(init_p2p); }); m.def("is_compiled_with_cuda", IsCompiledWithCUDA); + m.def("is_compiled_with_mkldnn", IsCompiledWithMKLDNN); m.def("is_compiled_with_brpc", IsCompiledWithBrpc); m.def("is_compiled_with_dist", IsCompiledWithDIST); #ifdef PADDLE_WITH_CUDA diff --git a/python/paddle/fluid/__init__.py b/python/paddle/fluid/__init__.py index a9c92efb7218213e1865d4757f1bda2a19b07e93..d12f04a6abefecbb8e3e43fd2f0b87e43264b07f 100644 --- a/python/paddle/fluid/__init__.py +++ b/python/paddle/fluid/__init__.py @@ -125,14 +125,13 @@ def __bootstrap__(): os.environ['OMP_NUM_THREADS'] = str(num_threads) sysstr = platform.system() read_env_flags = [ - 'check_nan_inf', 'benchmark', 'eager_delete_scope', 'use_mkldnn', - 'use_ngraph', 'initial_cpu_memory_in_mb', 'init_allocated_mem', - 'free_idle_memory', 'paddle_num_threads', "dist_threadpool_size", - 'eager_delete_tensor_gb', 'fast_eager_deletion_mode', - 'allocator_strategy', 'reader_queue_speed_test_mode', - 'print_sub_graph_dir', 'pe_profile_fname', 'warpctc_dir', - 'inner_op_parallelism', 'enable_parallel_graph', - 'multiple_of_cupti_buffer_size' + 'check_nan_inf', 'benchmark', 'eager_delete_scope', 'use_ngraph', + 'initial_cpu_memory_in_mb', 'init_allocated_mem', 'free_idle_memory', + 'paddle_num_threads', "dist_threadpool_size", 'eager_delete_tensor_gb', + 'fast_eager_deletion_mode', 'allocator_strategy', + 'reader_queue_speed_test_mode', 'print_sub_graph_dir', + 'pe_profile_fname', 'warpctc_dir', 'inner_op_parallelism', + 'enable_parallel_graph', 'multiple_of_cupti_buffer_size' ] if 'Darwin' not in sysstr: read_env_flags.append('use_pinned_memory') @@ -140,6 +139,9 @@ def __bootstrap__(): if os.name != 'nt': read_env_flags.append('cpu_deterministic') + if core.is_compiled_with_mkldnn(): + read_env_flags.append('use_mkldnn') + if core.is_compiled_with_dist(): read_env_flags.append('rpc_deadline') read_env_flags.append('rpc_server_profile_path')