|
15 | 15 |
|
16 | 16 | # Check whether the user has provided info about the GPU(s) installed |
17 | 17 | # on their system. If not, try to determine what it is automaticaly. |
18 | | -if(DEFINED ENV{CUDAARCHS}) |
19 | | - set(CMAKE_CUDA_ARCHITECTURES "$ENV{CUDAARCHS}") |
20 | | - message(STATUS "qsim: using CUDA archs string $ENV{CUDAARCHS}") |
| 18 | +if(CMAKE_CUDA_ARCHITECTURES) |
| 19 | + # CMake 3.18+ sets this variable from $CUDAARCHS automatically. |
| 20 | + message(STATUS "qsim: using CUDA architectures " |
| 21 | + "${CMAKE_CUDA_ARCHITECTURES}") |
21 | 22 | else() |
22 | | - find_program(NVIDIA_SMI nvidia-smi) |
23 | | - if(NVIDIA_SMI) |
24 | | - execute_process( |
25 | | - COMMAND ${NVIDIA_SMI} --query-gpu=compute_cap --format=csv,noheader |
26 | | - COMMAND tr -d . |
27 | | - OUTPUT_VARIABLE DETECTED_ARCHS |
28 | | - RESULT_VARIABLE NVIDIA_SMI_RESULT |
29 | | - OUTPUT_STRIP_TRAILING_WHITESPACE |
30 | | - ) |
31 | | - if(NVIDIA_SMI_RESULT EQUAL 0 AND DETECTED_ARCHS) |
32 | | - # The command was successful. The output may contain |
33 | | - # multiple lines if there are multiple GPUs. |
34 | | - string(REPLACE "\n" ";" ARCHS_LIST "${DETECTED_ARCHS}") |
35 | | - set(CMAKE_CUDA_ARCHITECTURES "${ARCHS_LIST}") |
36 | | - else() |
37 | | - message(FATAL_ERROR "nvidia-smi failed or returned no GPU" |
38 | | - " architectures. Please check your" |
39 | | - " NVIDIA driver installation and your" |
40 | | - " command search PATH variable.") |
41 | | - endif() |
42 | | - else() |
43 | | - message(FATAL_ERROR "nvidia-smi not found. Cannot autodetect" |
44 | | - " the current GPU architecture(s). Please" |
45 | | - " set the environment variable CUDAARCHS" |
46 | | - " to an appropriate value and try again.") |
47 | | - endif() |
| 23 | + # Compile for all supported major and minor real architectures, and the |
| 24 | + # highest major virtual architecture. |
| 25 | + set(CMAKE_CUDA_ARCHITECTURES native) |
48 | 26 | endif() |
49 | | - |
0 commit comments