-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support build with Ninja on Linux #44210
Changes from 9 commits
7e8ba9a
f24ec6e
644ce58
f6f206f
0b34029
c7dedea
473c2a1
d55837e
d689d16
0136c32
fa5b56c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,12 @@ else() | |
CACHE FILEPATH "mkldnn library." FORCE) | ||
endif() | ||
|
||
if(UNIX AND NOT APPLE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 目前Windows、Linux都支持ninja,这里副产物是不是除了mac都适用? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里是因为 windows 的 CI 有问题, mac 下 我没测试, 所以只在 linux 下设置 详细的log: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 还是改成if(NOT MAC),然后处理下Windows的情形,因为Windows现在也支持ninja There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里修改的细节见下面的回复, 根据 CI 的结果, windows 下不设置 可以在后面对 第三方库的 cmake 配置做统一的修改, 实现:
一些良好的参考, 比如 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个写 if(LINUX)吧,标准一些。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
set(BUILD_BYPRODUCTS_ARGS ${MKLDNN_LIB}) | ||
else() | ||
set(BUILD_BYPRODUCTS_ARGS "") | ||
endif() | ||
|
||
ExternalProject_Add( | ||
${MKLDNN_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} | ||
|
@@ -83,7 +89,8 @@ ExternalProject_Add( | |
-DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-DDNNL_BUILD_TESTS=OFF | ||
-DDNNL_BUILD_EXAMPLES=OFF | ||
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR}) | ||
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR} | ||
BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS_ARGS}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个BUILD_BYPRODUCTS是不是就是 ${MKLDNN_LIB},不用再设置新的变量了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
可以参考下这几次提交的 CI 失败结果, 这里的 BUILD_BYPRODUCTS 设置成 ${MKLDNN_LIB} 时, windows 的 CI 会失败, 这也是这个修改的原因 |
||
|
||
message(STATUS "MKLDNN library: ${MKLDNN_LIB}") | ||
add_definitions(-DPADDLE_WITH_MKLDNN) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ if(NOT WIN32) | |
PREFIX ${CBLAS_PREFIX_DIR} | ||
INSTALL_DIR ${CBLAS_INSTALL_DIR} | ||
BUILD_IN_SOURCE 1 | ||
BUILD_COMMAND make -j$(nproc) ${COMMON_ARGS} ${OPTIONAL_ARGS} | ||
BUILD_COMMAND make -j${NPROC} ${COMMON_ARGS} ${OPTIONAL_ARGS} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make 命令 在ninja时能否跑通 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上, 我这里测试时是 ok的, 这里和一些其他的一些写死使用 make的 三方库可以在后面慢慢更新成 配置使用 cmake 而不是 make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里编openblas,按道理调用了make -j 应该会出错呀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为什么会出错呢,这里 paddle 只需要用编译产物,具体编译过程是用 make 还是 ninja 还是裸调用 gcc 都是不关心的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
我是说应该让只安装了ninja 没有安装make的用户能编过,才算完整支持ninja。既然已经设置了CMAKE -GNinja,却还要背后里依赖其他的Generator是不合理的 |
||
INSTALL_COMMAND make install NO_SHARED=1 NO_LAPACK=1 PREFIX=<INSTALL_DIR> | ||
UPDATE_COMMAND "" | ||
CONFIGURE_COMMAND "" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个make -j 的命令在ninja时是否能编过?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ninja 下是ok的, 因为
${NPROC}
会被替换成 数字,build.ninja
里面不会出现$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个编dgc时是会用 make -j${NPROC} 来跑