Files
mscclpp/cmake/CheckNvidiaGpu.cmake
Changho Hwang fc0aaaf1b4 Auto-detect CUDA arch in CMake GPU check (#666)
Compute capability 60 support is dropped from CUDA 13

Co-authored-by: Binyang Li <binyli@microsoft.com>
2025-10-27 11:25:24 -07:00

36 lines
907 B
CMake

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
set(NVIDIA_FOUND "FALSE")
find_package(CUDAToolkit)
if(NOT CUDAToolkit_FOUND)
return()
endif()
set(CMAKE_CUDA_ARCHITECTURES native)
if(NOT CMAKE_CUDA_COMPILER)
# In case the CUDA Toolkit directory is not in the PATH
find_program(CUDA_COMPILER
NAMES nvcc
PATHS ${CUDAToolkit_BIN_DIR})
if(NOT CUDA_COMPILER)
message(WARNING "Could not find nvcc in ${CUDAToolkit_BIN_DIR}")
unset(CMAKE_CUDA_ARCHITECTURES)
return()
endif()
set(CMAKE_CUDA_COMPILER "${CUDA_COMPILER}")
endif()
enable_language(CUDA)
set(CHECK_SRC "${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_nvidia_gpu.cu")
try_run(RUN_RESULT COMPILE_SUCCESS SOURCES ${CHECK_SRC})
if(COMPILE_SUCCESS AND RUN_RESULT EQUAL 0)
set(NVIDIA_FOUND "TRUE")
else()
unset(CMAKE_CUDA_ARCHITECTURES)
endif()