Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6335e6a0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6335e6a0
编写于
10月 12, 2020
作者:
chen.zhiyu
提交者:
GitHub
10月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add musl option (#27798)
上级
e8a5aefb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
44 addition
and
19 deletion
+44
-19
CMakeLists.txt
CMakeLists.txt
+1
-0
cmake/configure.cmake
cmake/configure.cmake
+10
-0
paddle/fluid/inference/CMakeLists.txt
paddle/fluid/inference/CMakeLists.txt
+1
-1
paddle/fluid/inference/check_symbol.sh
paddle/fluid/inference/check_symbol.sh
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+8
-3
paddle/fluid/platform/macros.h
paddle/fluid/platform/macros.h
+2
-0
paddle/fluid/platform/port.h
paddle/fluid/platform/port.h
+4
-5
python/paddle/fluid/core.py
python/paddle/fluid/core.py
+17
-9
未找到文件。
CMakeLists.txt
浏览文件 @
6335e6a0
...
@@ -131,6 +131,7 @@ option(WITH_LITE "Compile Paddle Fluid with Lite Engine" OFF)
...
@@ -131,6 +131,7 @@ option(WITH_LITE "Compile Paddle Fluid with Lite Engine" OFF)
option
(
WITH_NCCL
"Compile PaddlePaddle with NCCL support"
ON
)
option
(
WITH_NCCL
"Compile PaddlePaddle with NCCL support"
ON
)
option
(
WITH_CRYPTO
"Compile PaddlePaddle with crypto support"
ON
)
option
(
WITH_CRYPTO
"Compile PaddlePaddle with crypto support"
ON
)
option
(
WITH_ARM
"Compile PaddlePaddle with arm support"
OFF
)
option
(
WITH_ARM
"Compile PaddlePaddle with arm support"
OFF
)
option
(
WITH_MUSL
"Compile with musl libc instead of gblic"
OFF
)
# PY_VERSION
# PY_VERSION
if
(
NOT PY_VERSION
)
if
(
NOT PY_VERSION
)
...
...
cmake/configure.cmake
浏览文件 @
6335e6a0
...
@@ -51,6 +51,16 @@ if(WIN32)
...
@@ -51,6 +51,16 @@ if(WIN32)
endif
(
NOT MSVC
)
endif
(
NOT MSVC
)
endif
(
WIN32
)
endif
(
WIN32
)
if
(
WITH_MUSL
)
add_definitions
(
-DPADDLE_WITH_MUSL
)
message
(
STATUS,
"Set compile option WITH_MKL=OFF when WITH_MUSL=ON"
)
SET
(
WITH_MKL OFF
)
message
(
STATUS,
"Set compile option WITH_GPU=OFF when WITH_MUSL=ON"
)
SET
(
WITH_GPU OFF
)
endif
()
if
(
WITH_PSLIB
)
if
(
WITH_PSLIB
)
add_definitions
(
-DPADDLE_WITH_PSLIB
)
add_definitions
(
-DPADDLE_WITH_PSLIB
)
endif
()
endif
()
...
...
paddle/fluid/inference/CMakeLists.txt
浏览文件 @
6335e6a0
...
@@ -88,7 +88,7 @@ if(NOT APPLE AND NOT WIN32)
...
@@ -88,7 +88,7 @@ if(NOT APPLE AND NOT WIN32)
set_target_properties
(
paddle_fluid_shared PROPERTIES LINK_FLAGS
"
${
LINK_FLAGS
}
"
)
set_target_properties
(
paddle_fluid_shared PROPERTIES LINK_FLAGS
"
${
LINK_FLAGS
}
"
)
# check symbol hidden
# check symbol hidden
FILE
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/check_symbol.cmake
FILE
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/check_symbol.cmake
"execute_process(COMMAND
ba
sh -c
\"
${
CMAKE_CURRENT_SOURCE_DIR
}
/check_symbol.sh"
"execute_process(COMMAND sh -c
\"
${
CMAKE_CURRENT_SOURCE_DIR
}
/check_symbol.sh"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/libpaddle_fluid.so
\"
RESULT_VARIABLE symbol_res)
\n
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/libpaddle_fluid.so
\"
RESULT_VARIABLE symbol_res)
\n
"
"if(NOT
\"\$
{symbol_res}
\"
STREQUAL
\"
0
\"
)
\n
"
"if(NOT
\"\$
{symbol_res}
\"
STREQUAL
\"
0
\"
)
\n
"
" message(FATAL_ERROR
\"
Check symbol failed.
\"
)
\n
"
" message(FATAL_ERROR
\"
Check symbol failed.
\"
)
\n
"
...
...
paddle/fluid/inference/check_symbol.sh
浏览文件 @
6335e6a0
#!/bin/
ba
sh
#!/bin/sh
lib
=
$1
lib
=
$1
if
[
$#
-ne
1
]
;
then
echo
"No input library"
;
exit
-1
;
fi
if
[
$#
-ne
1
]
;
then
echo
"No input library"
;
exit
-1
;
fi
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
6335e6a0
...
@@ -47,6 +47,10 @@ limitations under the License. */
...
@@ -47,6 +47,10 @@ limitations under the License. */
#include <type_traits>
#include <type_traits>
#include <utility>
#include <utility>
#if !defined(_WIN32) && !defined(PADDLE_WITH_MUSL)
#include <execinfo.h>
#endif
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/fluid/platform/errors.h"
#include "paddle/fluid/platform/errors.h"
...
@@ -236,13 +240,14 @@ inline std::string SimplifyDemangleStr(std::string str) {
...
@@ -236,13 +240,14 @@ inline std::string SimplifyDemangleStr(std::string str) {
}
}
inline
std
::
string
GetCurrentTraceBackString
()
{
inline
std
::
string
GetCurrentTraceBackString
()
{
static
constexpr
int
TRACE_STACK_LIMIT
=
100
;
std
::
ostringstream
sout
;
std
::
ostringstream
sout
;
sout
<<
"
\n\n
--------------------------------------
\n
"
;
sout
<<
"
\n\n
--------------------------------------
\n
"
;
sout
<<
"C++ Traceback (most recent call last):"
;
sout
<<
"C++ Traceback (most recent call last):"
;
sout
<<
"
\n
--------------------------------------
\n
"
;
sout
<<
"
\n
--------------------------------------
\n
"
;
#if !defined(_WIN32)
#if !defined(_WIN32) && !defined(PADDLE_WITH_MUSL)
static
constexpr
int
TRACE_STACK_LIMIT
=
100
;
void
*
call_stack
[
TRACE_STACK_LIMIT
];
void
*
call_stack
[
TRACE_STACK_LIMIT
];
auto
size
=
backtrace
(
call_stack
,
TRACE_STACK_LIMIT
);
auto
size
=
backtrace
(
call_stack
,
TRACE_STACK_LIMIT
);
auto
symbols
=
backtrace_symbols
(
call_stack
,
size
);
auto
symbols
=
backtrace_symbols
(
call_stack
,
size
);
...
@@ -261,7 +266,7 @@ inline std::string GetCurrentTraceBackString() {
...
@@ -261,7 +266,7 @@ inline std::string GetCurrentTraceBackString() {
}
}
free
(
symbols
);
free
(
symbols
);
#else
#else
sout
<<
"
Windows n
ot support stack backtrace yet.
\n
"
;
sout
<<
"
N
ot support stack backtrace yet.
\n
"
;
#endif
#endif
return
sout
.
str
();
return
sout
.
str
();
}
}
...
...
paddle/fluid/platform/macros.h
浏览文件 @
6335e6a0
...
@@ -25,6 +25,8 @@ limitations under the License. */
...
@@ -25,6 +25,8 @@ limitations under the License. */
classname& operator=(classname&&) = delete
classname& operator=(classname&&) = delete
#endif
#endif
#ifndef PADDLE_WITH_MUSL
#if defined(__FLT_MAX__)
#if defined(__FLT_MAX__)
#define FLT_MAX __FLT_MAX__
#define FLT_MAX __FLT_MAX__
#endif // __FLT_MAX__
#endif // __FLT_MAX__
#endif // PADDLE_WITH_MUSL
paddle/fluid/platform/port.h
浏览文件 @
6335e6a0
...
@@ -14,19 +14,18 @@
...
@@ -14,19 +14,18 @@
#pragma once
#pragma once
#include <cstdio>
#include <stdexcept>
#include <time.h>
#include <time.h>
#include <cstdio>
#include <memory>
#include <memory>
#include <stdexcept>
#include <string>
#include <string>
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#include "glog/logging.h"
#include "glog/logging.h"
#if !defined(_WIN32)
#if !defined(_WIN32)
#include <dlfcn.h> // dladdr
#include <dlfcn.h> // dladdr
#include <execinfo.h> // backtrace
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/time.h>
#include <algorithm> // std::accumulate
#include <algorithm> // std::accumulate
...
...
python/paddle/fluid/core.py
浏览文件 @
6335e6a0
...
@@ -205,8 +205,15 @@ def pre_load(dso_name):
...
@@ -205,8 +205,15 @@ def pre_load(dso_name):
load_dso
(
dso_path
)
load_dso
(
dso_path
)
def
get_glibc_ver
():
def
get_libc_ver
():
return
run_shell_command
(
"ldd --version | awk '/ldd/{print $NF}'"
)
ldd_glibc
=
run_shell_command
(
"ldd --version | awk '/ldd/{print $NF}'"
)
if
ldd_glibc
is
not
None
:
return
(
"glibc"
,
ldd_glibc
)
ldd_musl
=
run_shell_command
(
"ldd 2>&1 | awk '/Version/{print $NF}'"
)
if
ldd_musl
is
not
None
:
return
(
"musl"
,
ldd_musl
)
return
(
None
,
None
)
def
less_than_ver
(
a
,
b
):
def
less_than_ver
(
a
,
b
):
...
@@ -231,13 +238,14 @@ def less_than_ver(a, b):
...
@@ -231,13 +238,14 @@ def less_than_ver(a, b):
# For paddle, the problem is that 'libgomp' is a DSO with static TLS, and it is loaded after 14 DSOs.
# For paddle, the problem is that 'libgomp' is a DSO with static TLS, and it is loaded after 14 DSOs.
# So, here is a tricky way to solve the problem by pre load 'libgomp' before 'core_avx.so'.
# So, here is a tricky way to solve the problem by pre load 'libgomp' before 'core_avx.so'.
# The final solution is to upgrade glibc to > 2.22 on the target system.
# The final solution is to upgrade glibc to > 2.22 on the target system.
if
platform
.
system
().
lower
()
==
'linux'
and
less_than_ver
(
get_glibc_ver
(),
if
platform
.
system
().
lower
()
==
'linux'
:
'2.23'
):
libc_type
,
libc_ver
=
get_libc_ver
()
try
:
if
libc_type
==
'glibc'
and
less_than_ver
(
libc_ver
,
'2.23'
):
pre_load
(
'libgomp'
)
try
:
except
Exception
as
e
:
pre_load
(
'libgomp'
)
# NOTE(zhiqiu): do not abort if failed, since it may success when import core_avx.so
except
Exception
as
e
:
sys
.
stderr
.
write
(
'Error: Can not preload libgomp.so'
)
# NOTE(zhiqiu): do not abort if failed, since it may success when import core_avx.so
sys
.
stderr
.
write
(
'Error: Can not preload libgomp.so'
)
load_noavx
=
False
load_noavx
=
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录