Skip to content
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

throw errors when PyTorch CXX11 ABI is different from TensorFlow #3201

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,22 @@ if(ENABLE_TENSORFLOW AND NOT DEEPMD_C_ROOT)
endif()
if(ENABLE_PYTORCH AND NOT DEEPMD_C_ROOT)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
string(REGEX MATCH "_GLIBCXX_USE_CXX11_ABI=([0-9]+)" CXXABI_PT_MATCH
${TORCH_CXX_FLAGS})
if(CXXABI_PT_MATCH)
message(STATUS "PyTorch CXX11 ABI: ${CMAKE_MATCH_1}")
if(DEFINED OP_CXX_ABI)
if(NOT ${CMAKE_MATCH_1} EQUAL ${OP_CXX_ABI})
message(
FATAL_ERROR
"PyTorch CXX11 ABI mismatch TensorFlow: ${CMAKE_MATCH_1} != ${OP_CXX_ABI}"
)
endif()
else()
set(OP_CXX_ABI ${CMAKE_MATCH_1})
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=${OP_CXX_ABI})
endif()
endif()
endif()
# log enabled backends
if(NOT DEEPMD_C_ROOT)
Expand Down
Loading