From c88d5cdd06f33abde0102c9754bba48ba7c2b6e4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 16 Jun 2025 09:57:13 -0400 Subject: [PATCH] CUDAToolkit: Add CUDA 12.9 nvtx3 updates Starting in CUDA 12.9 the `nvToolsExt` library is no longer provided. C and C++ projects should switch over to `nvtx3`. Projects that previously used `nvToolsExt` with Fortran, can now use the new `CUDA::nvtx3_interop` target for the same functionality with the new NVTX v3 API. --- Modules/FindCUDAToolkit.cmake | 57 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 2455aabe55..b00cd26b7e 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -458,6 +458,7 @@ nvToolsExt .. deprecated:: 3.25 With CUDA 10.0+, use `nvtx3`_. + Starting in CUDA 12.9 the `nvToolsExt` library no longer exists The `legacy NVIDIA Tools Extension`_. This is a shared library only. @@ -482,6 +483,14 @@ Targets created: - ``CUDA::nvtx3`` + +- ``CUDA::nvtx3_interop`` + + .. versionadded:: 4.1 + + This is provided by CUDA 12.9 and above for use by languages that + cannot consume C++ header-only libraries, such as ``Fortran``. + .. _`NVIDIA Tools Extension`: https://nvidia.github.io/NVTX/doxygen OpenCL @@ -1394,26 +1403,7 @@ if(CUDAToolkit_FOUND) _CUDAToolkit_find_and_add_import_lib(nvml ALT nvidia-ml nvml) _CUDAToolkit_find_and_add_import_lib(nvml_static ONLY_SEARCH_FOR libnvidia-ml.a libnvml.a) - if(WIN32) - # nvtools can be installed outside the CUDA toolkit directory - # so prefer the NVTOOLSEXT_PATH windows only environment variable - # In addition on windows the most common name is nvToolsExt64_1 - find_library(CUDA_nvToolsExt_LIBRARY - NAMES nvToolsExt64_1 nvToolsExt64 nvToolsExt - PATHS ENV NVTOOLSEXT_PATH - ENV CUDA_PATH - PATH_SUFFIXES lib/x64 lib - ) - endif() - _CUDAToolkit_find_and_add_import_lib(nvToolsExt ALT nvToolsExt64) - if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.0) - # nvToolsExt is deprecated since nvtx3 introduction. - # Warn only if the project requires a sufficiently new CMake to make migration possible. - if(TARGET CUDA::nvToolsExt AND CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER_EQUAL 3.25) - set_property(TARGET CUDA::nvToolsExt PROPERTY DEPRECATION "nvToolsExt has been superseded by nvtx3 since CUDA 10.0 and CMake 3.25. Use CUDA::nvtx3 and include instead.") - endif() - # Header-only variant. Uses dlopen(). if(NOT TARGET CUDA::nvtx3) add_library(CUDA::nvtx3 INTERFACE IMPORTED) @@ -1421,6 +1411,35 @@ if(CUDAToolkit_FOUND) target_link_libraries(CUDA::nvtx3 INTERFACE ${CMAKE_DL_LIBS}) endif() endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.9) + if(NOT TARGET CUDA::nvtx3_interop) + _CUDAToolkit_find_and_add_import_lib(nvtx3_interop ALT nvtx3interop) + endif() + endif() + + # nvToolsExt is removed starting in 12.9 + if(CUDAToolkit_VERSION VERSION_LESS 12.9) + if(WIN32) + # nvtools can be installed outside the CUDA toolkit directory + # so prefer the NVTOOLSEXT_PATH windows only environment variable + # In addition on windows the most common name is nvToolsExt64_1 + find_library(CUDA_nvToolsExt_LIBRARY + NAMES nvToolsExt64_1 nvToolsExt64 nvToolsExt + PATHS ENV NVTOOLSEXT_PATH + ENV CUDA_PATH + PATH_SUFFIXES lib/x64 lib + ) + endif() + _CUDAToolkit_find_and_add_import_lib(nvToolsExt ALT nvToolsExt64) + + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.0) + # nvToolsExt is deprecated since nvtx3 introduction. + # Warn only if the project requires a sufficiently new CMake to make migration possible. + if(TARGET CUDA::nvToolsExt AND CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER_EQUAL 3.25) + set_property(TARGET CUDA::nvToolsExt PROPERTY DEPRECATION "nvToolsExt has been superseded by nvtx3 since CUDA 10.0 and CMake 3.25. Use CUDA::nvtx3 and include instead.") + endif() + endif() + endif() _CUDAToolkit_find_and_add_import_lib(OpenCL) endif()