diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index 69d20b8f77c29..b8bec9d0d04ad 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -22,7 +22,11 @@ if(WIN32) endif() set(MKLDNN_PATCH_COMMAND2 "") else() - set(MKLDNN_SHARED_LIB libmkldnn.so.0) + if (APPLE) + set(MKLDNN_SHARED_LIB libmkldnn.0.dylib) + else() + set(MKLDNN_SHARED_LIB libmkldnn.so.0) + endif() if(onnxruntime_USE_MKLML) set(DOWNLOAD_MKLML ${MKLDNN_SOURCE}/scripts/prepare_mkl.sh) set(MKLML_SHARED_LIB libmklml_intel.so) diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index 2411717001a73..22db4d45f2ea3 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -78,7 +78,10 @@ if (MSVC) elseif (APPLE) set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${ONNXRUNTIME_SO_LINK_FLAG}) - set_target_properties(onnxruntime_pybind11_state PROPERTIES INSTALL_RPATH "@loader_path") + set_target_properties(onnxruntime_pybind11_state PROPERTIES + INSTALL_RPATH "@loader_path" + BUILD_WITH_INSTALL_RPATH TRUE + INSTALL_RPATH_USE_LINK_PATH FALSE) else() target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${PYTHON_LIBRARY} ${ONNXRUNTIME_SO_LINK_FLAG}) set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-Xlinker -rpath=\$ORIGIN") diff --git a/setup.py b/setup.py index 2a8954809dcf3..812886f0bd71e 100644 --- a/setup.py +++ b/setup.py @@ -23,8 +23,10 @@ def finalize_options(self): bdist_wheel = None # Additional binaries -if platform.system() == 'Linux' or platform.system() == 'Darwin': +if platform.system() == 'Linux': libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.so.0', 'libmklml_intel.so', 'libiomp5.so'] +elif platform.system() == "Darwin": + libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.0.dylib'] # TODO add libmklml and libiomp5 later. else: libs = ['onnxruntime_pybind11_state.pyd', 'mkldnn.dll', 'mklml.dll', 'libiomp5md.dll']