Skip to content

Commit 494d862

Browse files
CUDA: mix virt/real CUDA archs for GGML_NATIVE=OFF
1 parent e291450 commit 494d862

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

ggml/src/ggml-cuda/CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,31 @@ if (CUDAToolkit_FOUND)
1212
# 61 == Pascal, __dp4a instruction (per-byte integer dot product)
1313
# 70 == V100, FP16 tensor cores
1414
# 75 == Turing, int8 tensor cores
15+
# 80 == Ampere, asynchronous data loading, faster tensor core instructions
16+
# 86 == RTX 3000, needs CUDA v11.1
17+
# 89 == RTX 4000, needs CUDA v11.8
18+
19+
#
20+
# XX-virtual == compile CUDA code as PTX, do JIT compilation to binary code on first run
21+
# XX-real == compile CUDA code as device code for this specific architecture
22+
# no suffix == compile as both PTX and device code
23+
#
24+
# The default behavior for a non-native is to build virtual architectures as needed to cover all features needed
25+
# for best performance and to also build real architectures for the most commonly used GPUs.
1526
if (GGML_NATIVE AND CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.6" AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
1627
set(CMAKE_CUDA_ARCHITECTURES "native")
1728
elseif(GGML_CUDA_F16 OR GGML_CUDA_DMMV_F16)
18-
set(CMAKE_CUDA_ARCHITECTURES "60;61;70;75;80")
29+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.8")
30+
set(CMAKE_CUDA_ARCHITECTURES "60-virtual;61-virtual;70-virtual;75-virtual;80-virtual;86-real;89-real")
31+
else()
32+
set(CMAKE_CUDA_ARCHITECTURES "60-virtual;61-virtual;70-virtual;75-virtual;80-virtual;86-real")
33+
endif()
1934
else()
20-
set(CMAKE_CUDA_ARCHITECTURES "50;61;70;75;80")
35+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.8")
36+
set(CMAKE_CUDA_ARCHITECTURES "50-virtual;61-virtual;70-virtual;75-virtual;80-virtual;86-real;89-real")
37+
else()
38+
set(CMAKE_CUDA_ARCHITECTURES "50-virtual;61-virtual;70-virtual;75-virtual;80-virtual;86-real")
39+
endif()
2140
endif()
2241
endif()
2342
message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")

0 commit comments

Comments
 (0)