Skip to content

Commit

Permalink
fix(pt): add libtorch directory to rpath
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Apr 2, 2024
1 parent 8e0cc90 commit d42bd8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ if(ENABLE_PYTORCH AND NOT DEEPMD_C_ROOT)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=${OP_CXX_ABI})
endif()
endif()
# get torch directory
set(PyTorch_LIBRARY_PATH ${TORCH_INCLUDE_DIRS}/../lib)
# trick: use TensorFlow_LIBRARY_PATH as general backend library paths
list(APPEND TensorFlow_LIBRARY_PATH ${PyTorch_LIBRARY_PATH})
endif()
# log enabled backends
if(NOT DEEPMD_C_ROOT)
Expand Down
4 changes: 2 additions & 2 deletions source/ipi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ if(APPLE)
${ipiname}
PROPERTIES LINK_FLAGS "${extra_link_flags}"
INSTALL_RPATH
"@loader_path/../${LIB_DIR}:${TensorFlow_LIBRARY_PATH}")
"@loader_path/../${LIB_DIR};${TensorFlow_LIBRARY_PATH}")
else()
set_target_properties(
${ipiname}
PROPERTIES LINK_FLAGS
"-Wl,-rpath,'$ORIGIN'/../${LIB_DIR} ${extra_link_flags}"
INSTALL_RPATH "$ORIGIN/../${LIB_DIR}:${TensorFlow_LIBRARY_PATH}")
INSTALL_RPATH "$ORIGIN/../${LIB_DIR};${TensorFlow_LIBRARY_PATH}")
endif()

if(CMAKE_TESTING_ENABLED)
Expand Down

0 comments on commit d42bd8e

Please sign in to comment.