From cb81c801d0d64c55ef0487e5640e4ddfe85a2f3a Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Sat, 13 Mar 2021 19:56:55 -0600 Subject: [PATCH] Fix auto-detecting GPU architectures (#727) Fixes regression from https://github.com/rapidsai/rmm/pull/726 in auto-detecting GPU architectures when `-DCMAKE_CUDA_ARCHITECTURES=` is passed on the CLI. Now that the cached `CMAKE_CUDA_ARCHITECTURES` isn't unset before calling `enable_language(CUDA)`, this call throws an error and configuration fails. This change ensures we call `enable_language(CUDA)` after any potential rewrites of `CMAKE_CUDA_ARCHITECTURES`. Authors: - Paul Taylor (@trxcllnt) Approvers: - Keith Kraus (@kkraus14) URL: https://github.com/rapidsai/rmm/pull/727 --- CMakeLists.txt | 3 ++- cmake/Modules/EvalGPUArchs.cmake | 8 +++++++- cmake/Modules/SetGPUArchs.cmake | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12eea27fb..46ec278ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,8 +97,9 @@ message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") if(BUILD_TESTS OR BUILD_BENCHMARKS) # Auto-detect available GPU compute architectures - enable_language(CUDA) include(${RMM_SOURCE_DIR}/cmake/Modules/SetGPUArchs.cmake) + # Enable the CUDA language after setting CMAKE_CUDA_ARCHITECTURES + enable_language(CUDA) message(STATUS "RMM: Building benchmarks with GPU Architectures: ${CMAKE_CUDA_ARCHITECTURES}") endif() diff --git a/cmake/Modules/EvalGPUArchs.cmake b/cmake/Modules/EvalGPUArchs.cmake index 1d9f72f1f..2a3904441 100644 --- a/cmake/Modules/EvalGPUArchs.cmake +++ b/cmake/Modules/EvalGPUArchs.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at @@ -10,6 +10,12 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. +# Unset this first in case it's set to +unset(CMAKE_CUDA_ARCHITECTURES CACHE) + +# Enable CUDA so we can invoke nvcc +enable_language(CUDA) + # Function uses the CUDA runtime API to query the compute capability of the device, so if a user # doesn't pass any architecture options to CMake we only build the current architecture function(evaluate_gpu_archs gpu_archs) diff --git a/cmake/Modules/SetGPUArchs.cmake b/cmake/Modules/SetGPUArchs.cmake index f43799a75..c37385a4c 100644 --- a/cmake/Modules/SetGPUArchs.cmake +++ b/cmake/Modules/SetGPUArchs.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at