Skip to content

Commit a4d2481

Browse files
committed
fix(pt): fix CMake compatibility with PyTorch 2.8
Fix #4877.
1 parent accc331 commit a4d2481

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

source/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,15 @@ if(ENABLE_PYTORCH AND NOT DEEPMD_C_ROOT)
373373
else()
374374
# Maybe in macos/windows
375375
if(NOT DEFINED OP_CXX_ABI)
376-
set(OP_CXX_ABI 0)
376+
if(UNIX
377+
AND NOT APPLE
378+
AND Torch_VERSION VERSION_GREATER_EQUAL "2.8.0")
379+
# https://github.com/deepmodeling/deepmd-kit/issues/4877
380+
# torch.compiled_with_cxx11_abi in PyTorch 2.8 always return True
381+
set(OP_CXX_ABI 1)
382+
else()
383+
set(OP_CXX_ABI 0)
384+
endif()
377385
endif()
378386
set(OP_CXX_ABI_PT "${OP_CXX_ABI}")
379387
endif()

0 commit comments

Comments
 (0)