|
|
|
@ -51,6 +51,7 @@ MSVC_LINK_FLAGS = ['/MACHINE:X64', 'paddle_custom_op.lib']
|
|
|
|
|
COMMON_NVCC_FLAGS = ['-DPADDLE_WITH_CUDA', '-DEIGEN_USE_GPU', '-O3']
|
|
|
|
|
|
|
|
|
|
GCC_MINI_VERSION = (5, 4, 0)
|
|
|
|
|
MSVC_MINI_VERSION = (19, 0, 24215)
|
|
|
|
|
# Give warning if using wrong compiler
|
|
|
|
|
WRONG_COMPILER_WARNING = '''
|
|
|
|
|
*************************************
|
|
|
|
@ -64,7 +65,7 @@ built Paddle for this platform, which is {paddle_compiler} on {platform}. Please
|
|
|
|
|
use {paddle_compiler} to compile your custom op. Or you may compile Paddle from
|
|
|
|
|
source using {user_compiler}, and then also use it compile your custom op.
|
|
|
|
|
|
|
|
|
|
See https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/2.0/install/compile/linux-compile.html
|
|
|
|
|
See https://www.paddlepaddle.org.cn/documentation/docs/zh/install/compile/fromsource.html
|
|
|
|
|
for help with compiling Paddle from source.
|
|
|
|
|
|
|
|
|
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
@ -877,13 +878,12 @@ def check_abi_compatibility(compiler, verbose=False):
|
|
|
|
|
Check whether GCC version on user local machine is compatible with Paddle in
|
|
|
|
|
site-packages.
|
|
|
|
|
"""
|
|
|
|
|
# TODO(Aurelius84): After we support windows, remove IS_WINDOWS in following code.
|
|
|
|
|
if os.environ.get('PADDLE_SKIP_CHECK_ABI') in ['True', 'true', '1'
|
|
|
|
|
] or IS_WINDOWS:
|
|
|
|
|
if os.environ.get('PADDLE_SKIP_CHECK_ABI') in ['True', 'true', '1']:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
which = 'where' if IS_WINDOWS else 'which'
|
|
|
|
|
cmd_out = subprocess.check_output(
|
|
|
|
|
['which', compiler], stderr=subprocess.STDOUT)
|
|
|
|
|
[which, compiler], stderr=subprocess.STDOUT)
|
|
|
|
|
compiler_path = os.path.realpath(cmd_out.decode()
|
|
|
|
|
if six.PY3 else cmd_out).strip()
|
|
|
|
|
# step 1. if not found any suitable compiler, raise error
|
|
|
|
@ -896,32 +896,41 @@ def check_abi_compatibility(compiler, verbose=False):
|
|
|
|
|
platform=OS_NAME))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
version = (0, 0, 0)
|
|
|
|
|
# clang++ have no ABI compatibility problem
|
|
|
|
|
if OS_NAME.startswith('darwin'):
|
|
|
|
|
return True
|
|
|
|
|
try:
|
|
|
|
|
if OS_NAME.startswith('linux'):
|
|
|
|
|
mini_required_version = GCC_MINI_VERSION
|
|
|
|
|
version_info = subprocess.check_output(
|
|
|
|
|
[compiler, '-dumpfullversion', '-dumpversion'])
|
|
|
|
|
if six.PY3:
|
|
|
|
|
version_info = version_info.decode()
|
|
|
|
|
version = version_info.strip().split('.')
|
|
|
|
|
assert len(version) == 3
|
|
|
|
|
# check version compatibility
|
|
|
|
|
if tuple(map(int, version)) >= GCC_MINI_VERSION:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
ABI_INCOMPATIBILITY_WARNING.format(
|
|
|
|
|
user_compiler=compiler, version=version_info.strip()))
|
|
|
|
|
elif IS_WINDOWS:
|
|
|
|
|
# TODO(zhouwei): support check abi compatibility on windows
|
|
|
|
|
warnings.warn("We don't support Windows now.")
|
|
|
|
|
mini_required_version = MSVC_MINI_VERSION
|
|
|
|
|
compiler_info = subprocess.check_output(
|
|
|
|
|
compiler, stderr=subprocess.STDOUT)
|
|
|
|
|
if six.PY3:
|
|
|
|
|
compiler_info = compiler_info.decode()
|
|
|
|
|
match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.strip())
|
|
|
|
|
if match is not None:
|
|
|
|
|
version = match.groups()
|
|
|
|
|
except Exception:
|
|
|
|
|
# check compiler version failed
|
|
|
|
|
_, error, _ = sys.exc_info()
|
|
|
|
|
warnings.warn('Failed to check compiler version for {}: {}'.format(
|
|
|
|
|
compiler, error))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# check version compatibility
|
|
|
|
|
assert len(version) == 3
|
|
|
|
|
if tuple(map(int, version)) >= mini_required_version:
|
|
|
|
|
return True
|
|
|
|
|
warnings.warn(
|
|
|
|
|
ABI_INCOMPATIBILITY_WARNING.format(
|
|
|
|
|
user_compiler=compiler, version=version.strip()))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -929,8 +938,12 @@ def _expected_compiler_current_platform():
|
|
|
|
|
"""
|
|
|
|
|
Returns supported compiler string on current platform
|
|
|
|
|
"""
|
|
|
|
|
expect_compilers = ['clang', 'clang++'] if OS_NAME.startswith(
|
|
|
|
|
'darwin') else ['gcc', 'g++', 'gnu-c++', 'gnu-cc']
|
|
|
|
|
if OS_NAME.startswith('darwin'):
|
|
|
|
|
expect_compilers = ['clang', 'clang++']
|
|
|
|
|
elif OS_NAME.startswith('linux'):
|
|
|
|
|
expect_compilers = ['gcc', 'g++', 'gnu-c++', 'gnu-cc']
|
|
|
|
|
elif IS_WINDOWS:
|
|
|
|
|
expect_compilers = ['cl']
|
|
|
|
|
return expect_compilers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|