From 4696c59e10320725ff5dad0cccebf343b476db6b Mon Sep 17 00:00:00 2001 From: Deeven Seru Date: Mon, 19 Oct 2026 13:42:42 +0530 Subject: [PATCH] #4887 - Conditionally gate SM 100/120 on CUDA 12.8+ in default CMAKE_CUDA_ARCHITECTURES In TensorRT 11.4 OSS release (#4872), CMAKE_CUDA_ARCHITECTURES was defaulted to include SM 100 and SM 120 unconditionally before CUDAToolkit was discovered. However, SM 100 and SM 120 (Blackwell) require CUDA 12.8+ to be supported by nvcc. Building on CUDA toolkits < 12.8 (such as CUDA 12.0 - 12.6) caused nvcc to immediately fail with 'Value sm_100 is not defined for option gpu-architecture'. This patch: - Defaults CMAKE_CUDA_ARCHITECTURES to SM 75 80 86 89 90 prior to toolkit discovery. - Conditionally appends SM 100 and SM 120 once CUDAToolkit_VERSION >= 12.8 is confirmed, matching the existing conditional logic for SM 110 (Thor, CUDA >= 13.0). - Fixes NVRTC version check in plugin_utils.py to check (nvrtc_major, nvrtc_minor) >= (11, 1), preventing CUDA 12.0/13.0 from incorrectly disabling CUBIN generation. Fixes #4887 Signed-off-by: Deeven Seru --- CMakeLists.txt | 12 +++++++++--- samples/python/plugin_utils.py | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 243614361d..6119b9bb0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,10 @@ set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS ON) # Set CMAKE_CUDA_ARCHITECTURES before project() so CMake's CMP0104 policy does not # auto-detect and overwrite it with the host GPU's SM. CUDAToolkit_VERSION is not -# available yet; SM 110 is conditionally appended after find_package(CUDAToolkit) below. +# available yet; SM 100/120 (Blackwell) and SM 110 (Thor) are conditionally appended +# after find_package(CUDAToolkit) below based on the discovered toolkit version. if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - set(CMAKE_CUDA_ARCHITECTURES 75 80 86 89 90 100 120) + set(CMAKE_CUDA_ARCHITECTURES 75 80 86 89 90) set(_TRT_CUDA_ARCHS_DEFAULTED TRUE) endif() @@ -89,8 +90,13 @@ endif() find_package(CUDAToolkit REQUIRED) message(STATUS "CUDA version: ${CUDAToolkit_VERSION}") -# SM 110 (Thor) requires CUDA 13.0+. +# SM 100 and SM 120 (Blackwell) require CUDA 12.8+. # CUDAToolkit_VERSION is only available once the toolkit is found. +if (_TRT_CUDA_ARCHS_DEFAULTED AND CUDAToolkit_VERSION VERSION_GREATER_EQUAL "12.8") + list(APPEND CMAKE_CUDA_ARCHITECTURES 100 120) +endif() + +# SM 110 (Thor) requires CUDA 13.0+. if (_TRT_CUDA_ARCHS_DEFAULTED AND CUDAToolkit_VERSION VERSION_GREATER_EQUAL "13.0") list(APPEND CMAKE_CUDA_ARCHITECTURES 110) endif() diff --git a/samples/python/plugin_utils.py b/samples/python/plugin_utils.py index 8a099632e6..09544977c0 100644 --- a/samples/python/plugin_utils.py +++ b/samples/python/plugin_utils.py @@ -74,8 +74,8 @@ def __init__(self, code, devID): cuda_call(cudart.cudaFree(0)) major, minor = getComputeCapacity(devID) - _, nvrtc_minor = cuda_call(nvrtc.nvrtcVersion()) - use_cubin = nvrtc_minor >= 1 + nvrtc_major, nvrtc_minor = cuda_call(nvrtc.nvrtcVersion()) + use_cubin = (nvrtc_major, nvrtc_minor) >= (11, 1) prefix = "sm" if use_cubin else "compute" arch_arg = bytes(f"--gpu-architecture={prefix}_{major}{minor}", "ascii")