Skip to content

Commit 147d84e

Browse files
committed
feat: use FindCUDAToolkit for robust CUDA detection
1 parent 313a580 commit 147d84e

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ if(USE_GPU AND NOT FORCE_CPU)
2020
set(GGML_METAL ON CACHE BOOL "" FORCE)
2121
set(SUBGEN_GPU_BACKEND "Metal")
2222
elseif(WIN32 OR (UNIX AND NOT APPLE))
23-
include(CheckLanguage)
24-
check_language(CUDA)
25-
if(CMAKE_CUDA_COMPILER)
26-
enable_language(CUDA)
23+
find_package(CUDAToolkit QUIET)
24+
if(CUDAToolkit_FOUND)
2725
set(GGML_CUDA ON CACHE BOOL "" FORCE)
2826
set(SUBGEN_GPU_BACKEND "CUDA")
27+
message(STATUS "CUDA toolkit found -- building with CUDA support")
2928
else()
30-
message(STATUS "No CUDA toolkit found at configure time -- building CPU-only. "
31-
"(GPU is still used automatically at runtime if you later "
32-
"rebuild on a machine with the CUDA toolkit installed.)")
29+
include(CheckLanguage)
30+
check_language(CUDA)
31+
if(CMAKE_CUDA_COMPILER)
32+
enable_language(CUDA)
33+
set(GGML_CUDA ON CACHE BOOL "" FORCE)
34+
set(SUBGEN_GPU_BACKEND "CUDA")
35+
message(STATUS "CUDA toolkit found (fallback) -- building with CUDA support")
36+
else()
37+
message(STATUS "No CUDA toolkit found -- building CPU-only. "
38+
"(Install CUDA toolkit from nvidia.com and rebuild to enable GPU acceleration.)")
39+
endif()
3340
endif()
3441
endif()
3542
else()

0 commit comments

Comments
 (0)