From d42bd8ed251088e910df50d7680afdf0e3414760 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 1 Apr 2024 23:54:42 -0400 Subject: [PATCH] fix(pt): add libtorch directory to rpath Signed-off-by: Jinzhe Zeng --- source/CMakeLists.txt | 4 ++++ source/ipi/CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 02f2993912..2aa7bb93e1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -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) diff --git a/source/ipi/CMakeLists.txt b/source/ipi/CMakeLists.txt index 5d571a1950..afb8a03261 100644 --- a/source/ipi/CMakeLists.txt +++ b/source/ipi/CMakeLists.txt @@ -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)