Skip to content

Commit

Permalink
Fix auto-detecting GPU architectures (#727)
Browse files Browse the repository at this point in the history
Fixes regression from #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: #727
  • Loading branch information
trxcllnt authored Mar 14, 2021
1 parent 304c04d commit cb81c80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 7 additions & 1 deletion cmake/Modules/EvalGPUArchs.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <empty_string>
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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/SetGPUArchs.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit cb81c80

Please sign in to comment.