@@ -45,23 +45,25 @@ if (CUDAToolkit_FOUND)
4545
4646 enable_language (CUDA )
4747
48- # Replace any 12x-real architectures with 12x{a}-real. FP4 ptx instructions are not available in just 12x
49- set (PROCESSED_ARCHITECTURES "" )
5048 if (GGML_NATIVE)
51- foreach (ARCH ${CMAKE_CUDA_ARCHITECTURES_NATIVE} )
52- if (ARCH MATCHES "^12[0-9af]+" )
53- # Extract the base architecture number (e.g., "120" or "120f")
54- string (REGEX REPLACE "^(12[0-9]+).*$" "\\ 1" BASE_ARCH ${ARCH} )
55- # Replace with 12xa-real
56- message (STATUS "Replacing ${ARCH} with ${BASE_ARCH} a-real" )
57- list (APPEND PROCESSED_ARCHITECTURES "${BASE_ARCH} a-real" )
58- else ()
59- list (APPEND PROCESSED_ARCHITECTURES ${ARCH} )
60- endif ()
61- endforeach ()
62- set (CMAKE_CUDA_ARCHITECTURES ${PROCESSED_ARCHITECTURES} )
49+ set (ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES_NATIVE} )
50+ else ()
51+ set (ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES} )
6352 endif ()
6453
54+ # Replace any 12x-real architectures with 12x{a}-real. FP4 ptx instructions are not available in just 12x
55+ set (PROCESSED_ARCHITECTURES "" )
56+ foreach (ARCH ${ARCH_LIST} )
57+ if (ARCH MATCHES "^12[0-9]" )
58+ string (REGEX REPLACE "^(12[0-9]).*$" "\\ 1" BASE_ARCH ${ARCH} )
59+ message (STATUS "Replacing ${ARCH} with ${BASE_ARCH} a-real" )
60+ list (APPEND PROCESSED_ARCHITECTURES "${BASE_ARCH} a-real" )
61+ else ()
62+ list (APPEND PROCESSED_ARCHITECTURES ${ARCH} )
63+ endif ()
64+ endforeach ()
65+ set (CMAKE_CUDA_ARCHITECTURES ${PROCESSED_ARCHITECTURES} )
66+
6567 file (GLOB GGML_HEADERS_CUDA "*.cuh" )
6668 list (APPEND GGML_HEADERS_CUDA "../../include/ggml-cuda.h" )
6769
0 commit comments