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

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

* refine core cmake warning and print more info

test=develop

* fix comments

test=develop
上级 32c95f17
...@@ -14,8 +14,12 @@ set(FLUID_CORE_NAME "core") ...@@ -14,8 +14,12 @@ set(FLUID_CORE_NAME "core")
if(WITH_AVX AND AVX_FOUND) if(WITH_AVX AND AVX_FOUND)
set(FLUID_CORE_NAME "${FLUID_CORE_NAME}_avx") set(FLUID_CORE_NAME "${FLUID_CORE_NAME}_avx")
if(NOT DEFINED NOAVX_CORE_FILE OR NOAVX_CORE_FILE STREQUAL "") if(NOT DEFINED NOAVX_CORE_FILE OR NOAVX_CORE_FILE STREQUAL "")
message(WARNING "You are building AVX version without NOAVX core, \ message(STATUS "WARNING: This is just a warning for publishing release.
and the wheel package may fail on NOAVX machine.") 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() endif()
if(NOAVX_CORE_FILE AND NOT EXISTS "${NOAVX_CORE_FILE}") if(NOAVX_CORE_FILE AND NOT EXISTS "${NOAVX_CORE_FILE}")
......
...@@ -14,6 +14,23 @@ ...@@ -14,6 +14,23 @@
from __future__ import print_function from __future__ import print_function
import os 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 # import all class inside framework into fluid module
from . import framework from . import framework
from .framework import * from .framework import *
......
...@@ -18,10 +18,23 @@ import sys ...@@ -18,10 +18,23 @@ import sys
import os import os
from cpuinfo import get_cpu_info 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: try:
if os.name == 'nt': if os.name == 'nt':
third_lib_path = os.path.abspath(os.path.dirname( third_lib_path = current_path + os.sep + '..' + os.sep + 'libs'
__file__)) + os.sep + '..' + os.sep + 'libs'
os.environ['path'] += ';' + third_lib_path os.environ['path'] += ';' + third_lib_path
sys.path.append(third_lib_path) sys.path.append(third_lib_path)
...@@ -59,12 +72,17 @@ if 'avx' in get_cpu_info()['flags']: ...@@ -59,12 +72,17 @@ if 'avx' in get_cpu_info()['flags']:
from .core_avx import _set_fuse_parameter_memory_size from .core_avx import _set_fuse_parameter_memory_size
from .core_avx import _is_dygraph_debug_enabled from .core_avx import _is_dygraph_debug_enabled
from .core_avx import _dygraph_debug_level from .core_avx import _dygraph_debug_level
except ImportError: except ImportError as e:
sys.stderr.write( if has_avx_core:
'WARNING: Can not import avx core. You may not build with AVX, ' raise e
'but AVX is supported on local machine, you could build paddle ' else:
'WITH_AVX=ON to get better performance. ') sys.stderr.write(
load_noavx = True '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: else:
load_noavx = True load_noavx = True
...@@ -82,7 +100,11 @@ if load_noavx: ...@@ -82,7 +100,11 @@ if load_noavx:
from .core_noavx import _set_fuse_parameter_memory_size from .core_noavx import _set_fuse_parameter_memory_size
from .core_noavx import _is_dygraph_debug_enabled from .core_noavx import _is_dygraph_debug_enabled
from .core_noavx import _dygraph_debug_level from .core_noavx import _dygraph_debug_level
except ImportError as error: except ImportError as e:
sys.exit("Error: Can not load core_noavx.* ." + if has_noavx_core:
error.__class__.__name__) sys.stderr.write(
load_noavx = True '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.
先完成此消息的编辑!
想要评论请 注册