-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build mkldnn as static lib on mac/linux #13197
Conversation
@mxnet-label-bot add [mkldnn, build] |
50ebcbb
to
e2422d6
Compare
@mxnet-label-bot add [pr-work-in-progress] |
@marcoabreu do you have any idea why mxnet_unit_test still links to libmkldnn.so.0? |
@TaoLv can you take a look at this and help me find where we still link libmkldnn.so.0 in the CI? |
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.
Seems https://github.com/apache/incubator-mxnet/blob/master/tests/python/mkl/test_mkldnn_install.py#L27 also need be refactored.
CMakeLists.txt
Outdated
@@ -225,6 +225,7 @@ endif() | |||
|
|||
if(USE_MKLDNN) | |||
include(cmake/DownloadMKLML.cmake) | |||
SET(MKLDNN_LIBRARY_TYPE STATIC) |
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.
Try set(MKLDNN_LIBRARY_TYPE "STATIC" CACHE INTERNAL "" FORCE)
43cc63e
to
d103ec8
Compare
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.
Looks good!
Makefile
Outdated
|
||
ifneq ($(UNAME_S), Windows) | ||
LIB_DEP += $(MKLDNNROOT)/lib/libmkldnn.a | ||
else |
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.
Indentation does not look right, could you please double check?
Makefile
Outdated
else | ||
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
endif |
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.
nit: indentation
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.
it's for the ifeq on line 126.
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.
Why isn't this aligned with L126 then?
ifeq ($(UNAME_S), Darwin) | ||
OMP_LIBFILE = $(MKLDNNROOT)/lib/libiomp5.dylib | ||
MKLML_LIBFILE = $(MKLDNNROOT)/lib/libmklml.dylib | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.0.dylib | ||
MKLDNN_LIBFILE = $(MKLDNNROOT)/lib/libmkldnn.a | ||
else ifeq ($(UNAME_S), Windows) |
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.
Do we need a endif
for this ifeq
? Maybe better to break the line so it will be shown RED in web browser?
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.
NVM, seems this is correct syntax in Makefile.
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.
LGTM
e1d1f60
to
232f6d4
Compare
09de96b
to
e1d1f60
Compare
e1d1f60
to
13304ba
Compare
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
|
||
ifneq ($(UNAME_S), Windows) |
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.
Should we add a reason here, on why on Windows, it is dynamically linked for future maintenance?
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.
+1 for adding comments. Also curious about how MKL BLAS is linked on Windows?
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.
updated comment in #13503.
Re-triggering failed CI. |
CFLAGS += -I$(MKLDNNROOT)/include | ||
LDFLAGS += -L$(MKLDNNROOT)/lib -lmkldnn -Wl,-rpath,'$${ORIGIN}' | ||
|
||
ifneq ($(UNAME_S), Windows) |
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.
+1 for adding comments. Also curious about how MKL BLAS is linked on Windows?
|
||
|
||
if __name__ == '__main__': | ||
install.test_mkldnn_install() |
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.
Need make sure about the purpose of a test case before removing it. If this case is just for verifying whether MKL-DNN so is correctly linked, I'm OK with removing it. Otherwise, need replace it with something else.
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.
The test looks if mkldnn appears on the memory table of the process running mxnet.I have verified manually (by cat /proc/{id}/maps | grep mkldnn
) that mkldnn use to appear in the table when it is dynamically linked but no longer does (statically linked).
the second part of this just checks the response code (rc - probably to make sure the proc/{id}/maps file even exists).
@pengzhao-intel is there another reason this test was added
#13503 has been merged. closing this PR. |
Description
currently MKLDNN is dynamically linked to mxnet. This can cause some issues if another version of mkldnn is present on the host machine and mxnet links to the host version. This change statically builds mkldnn into mxnet to handle version issues on linux/mac but keeps it dynamically linked on windows.
removed test_mkldnn_install.py from test as well since it tests if mkldnn is dynamically linked on linux (which it is no longe)
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments