diff --git a/ggml/src/ggml-cuda/CMakeLists.txt b/ggml/src/ggml-cuda/CMakeLists.txt index f3c3ebff7ea..c0f8bcaa378 100644 --- a/ggml/src/ggml-cuda/CMakeLists.txt +++ b/ggml/src/ggml-cuda/CMakeLists.txt @@ -44,8 +44,13 @@ if (CUDAToolkit_FOUND) # Replace any 12x-real architectures with 12x{a}-real. FP4 ptx instructions are not available in just 12x if (GGML_NATIVE) set(PROCESSED_ARCHITECTURES "") - foreach(ARCH ${CMAKE_CUDA_ARCHITECTURES_NATIVE}) - if(ARCH MATCHES "^12[0-9]$") + if (CMAKE_CUDA_ARCHITECTURES_NATIVE) + set(ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES_NATIVE}) + else() + set(ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES}) + endif() + foreach(ARCH ${ARCH_LIST}) + if (ARCH MATCHES "^12[0-9](-real|-virtual)?$") string(REGEX REPLACE "^(12[0-9]).*$" "\\1" BASE_ARCH ${ARCH}) message(STATUS "Replacing ${ARCH} with ${BASE_ARCH}a-real") list(APPEND PROCESSED_ARCHITECTURES "${BASE_ARCH}a-real")