未验证 提交 575bc572 编写于 作者: T tensor-tang 提交者: GitHub

cherry pick refine core cmake warning and print more info (#18248) (#18267)

* refine core cmake warning and print more info
* fix comments

test=release/1.5
上级 dd4b29c2
......@@ -14,8 +14,12 @@ set(FLUID_CORE_NAME "core")
if(WITH_AVX AND AVX_FOUND)
set(FLUID_CORE_NAME "${FLUID_CORE_NAME}_avx")
if(NOT DEFINED NOAVX_CORE_FILE OR NOAVX_CORE_FILE STREQUAL "")
message(WARNING "You are building AVX version without NOAVX core, \
and the wheel package may fail on NOAVX machine.")
message(STATUS "WARNING: This is just a warning for publishing release.
You are building AVX version without NOAVX core.
So the wheel package may fail on NOAVX machine.
You can add -DFLUID_CORE_NAME=/path/to/your/core_noavx.* in cmake command
to get a full wheel package to resolve this warning.
While, this version will still work on local machine.")
endif()
if(NOAVX_CORE_FILE AND NOT EXISTS "${NOAVX_CORE_FILE}")
......
......@@ -14,6 +14,23 @@
from __future__ import print_function
import os
import sys
# The legacy core need to be removed before "import core",
# in case of users installing paddlepadde without -U option
core_suffix = 'so'
if os.name == 'nt':
core_suffix = 'pyd'
legacy_core = os.path.abspath(os.path.dirname(
__file__)) + os.sep + 'core.' + core_suffix
if os.path.exists(legacy_core):
sys.stderr.write('Deleting legacy file ' + legacy_core + '\n')
try:
os.remove(legacy_core)
except Exception as e:
raise e
# import all class inside framework into fluid module
from . import framework
from .framework import *
......
......@@ -18,10 +18,23 @@ import sys
import os
from cpuinfo import get_cpu_info
core_suffix = 'so'
if os.name == 'nt':
core_suffix = 'pyd'
has_avx_core = False
has_noavx_core = False
current_path = os.path.abspath(os.path.dirname(__file__))
if os.path.exists(current_path + os.sep + 'core_avx.' + core_suffix):
has_avx_core = True
if os.path.exists(current_path + os.sep + 'core_noavx.' + core_suffix):
has_noavx_core = True
try:
if os.name == 'nt':
third_lib_path = os.path.abspath(os.path.dirname(
__file__)) + os.sep + '..' + os.sep + 'libs'
third_lib_path = current_path + os.sep + '..' + os.sep + 'libs'
os.environ['path'] += ';' + third_lib_path
sys.path.append(third_lib_path)
......@@ -59,12 +72,17 @@ if 'avx' in get_cpu_info()['flags']:
from .core_avx import _set_fuse_parameter_memory_size
from .core_avx import _is_dygraph_debug_enabled
from .core_avx import _dygraph_debug_level
except ImportError:
sys.stderr.write(
'WARNING: Can not import avx core. You may not build with AVX, '
'but AVX is supported on local machine, you could build paddle '
'WITH_AVX=ON to get better performance. ')
load_noavx = True
except ImportError as e:
if has_avx_core:
raise e
else:
sys.stderr.write(
'WARNING: Do not have avx core. You may not build with AVX, '
'but AVX is supported on local machine.\n You could build paddle '
'WITH_AVX=ON to get better performance.\n')
load_noavx = True
except Exception as e:
raise e
else:
load_noavx = True
......@@ -82,7 +100,11 @@ if load_noavx:
from .core_noavx import _set_fuse_parameter_memory_size
from .core_noavx import _is_dygraph_debug_enabled
from .core_noavx import _dygraph_debug_level
except ImportError as error:
sys.exit("Error: Can not load core_noavx.* ." +
error.__class__.__name__)
load_noavx = True
except ImportError as e:
if has_noavx_core:
sys.stderr.write(
'Error: Can not import noavx core while this file exists ' +
current_path + os.sep + 'core_noavx.' + core_suffix + '\n')
raise e
except Exception as e:
raise e
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册