11file (GLOB OP_SRC print_summary.cc comm.cc tabulate_multi_device.cc )
2- # Fused graph-lower inference operators (CUDA / cuBLAS); GPU builds only. The
3- # CUDA language is scoped per directory, so it must be enabled here: the sibling
4- # GPU library turns it on only within its own subtree, which does not cover this
5- # target.
6- if (USE_CUDA_TOOLKIT)
2+ # Fused graph-lower inference operators (CUDA / cuBLAS). They include ATen CUDA
3+ # headers and link libtorch_cuda, so they build only against a CUDA-enabled
4+ # PyTorch (DEEPMD_TORCH_HAS_CUDA); against a CPU-only torch they are omitted and
5+ # the Python dispatch falls back to the reference path (see
6+ # deepmd.kernels.cuda.*.op_available). The CUDA language is scoped per
7+ # directory, so it must be enabled here: the sibling GPU library turns it on
8+ # only within its own subtree, which does not cover this target.
9+ if (USE_CUDA_TOOLKIT AND DEEPMD_TORCH_HAS_CUDA)
710 find_package (CUDAToolkit REQUIRED )
811 if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
912 # CUDA 12.9 and 13.x CCCL fail to compile CUB/Thrust with -arch=all.
@@ -28,7 +31,7 @@ endif()
2831add_library (deepmd_op_pt MODULE ${OP_SRC} )
2932# link: libdeepmd libtorch
3033target_link_libraries (deepmd_op_pt PRIVATE ${TORCH_LIBRARIES} )
31- if (USE_CUDA_TOOLKIT)
34+ if (USE_CUDA_TOOLKIT AND DEEPMD_TORCH_HAS_CUDA )
3235 target_link_libraries (deepmd_op_pt PRIVATE CUDA::cublas )
3336 # libtorch headers require C++17; the CUDA sources must match.
3437 set_target_properties (deepmd_op_pt PROPERTIES CUDA_STANDARD 17
0 commit comments