From b0efed384375a36fb9b0c392578b08705146853b Mon Sep 17 00:00:00 2001 From: Felix Kaechele Date: Tue, 22 Jul 2025 13:39:24 -0400 Subject: [PATCH 1/3] Fix for CUDA 12 nvtx3 library detection --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3433480..a234ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,19 @@ if(CMAKE_CUDA_COMPILER) set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CUDA_STANDARD_REQUIRED ON) + if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + message(STATUS "PyTorch NVTX headers workaround: Yes") + # only do this if nvToolsExt is not defined and CUDA::nvtx3 exists + if(NOT TARGET CUDA::nvToolsExt AND TARGET CUDA::nvtx3) + add_library(CUDA::nvToolsExt INTERFACE IMPORTED) + # ensure that PyTorch is told to use NVTX3 headers + target_compile_definitions(CUDA::nvToolsExt INTERFACE TORCH_CUDA_USE_NVTX3) + target_link_libraries(CUDA::nvToolsExt INTERFACE CUDA::nvtx3) + endif() + else() + message(STATUS "PyTorch NVTX headers workaround: No") + endif() + message(STATUS "INSTALLING EXTENSIONS WITH CUDA!") string(REGEX REPLACE ".[0-9][0-9]|\\." "" CUDA_V ${CMAKE_CUDA_COMPILER_VERSION}) message(STATUS "CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER}") From 50dc287fddd2236cc513c3f16a55a081dbc3b8a4 Mon Sep 17 00:00:00 2001 From: Felix Kaechele Date: Sun, 14 Sep 2025 14:30:48 -0400 Subject: [PATCH 2/3] Update CMakeLists.txt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a234ca9..c13c2a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,10 @@ if(CMAKE_CUDA_COMPILER) # only do this if nvToolsExt is not defined and CUDA::nvtx3 exists if(NOT TARGET CUDA::nvToolsExt AND TARGET CUDA::nvtx3) add_library(CUDA::nvToolsExt INTERFACE IMPORTED) - # ensure that PyTorch is told to use NVTX3 headers + # The TORCH_CUDA_USE_NVTX3 compile definition tells PyTorch to use the NVTX3 headers + # instead of the legacy NVTX headers. This is necessary when building with CUDA 12+ + # and the CUDA::nvtx3 target is available, but CUDA::nvToolsExt is not defined. + # Without this definition, PyTorch may fail to find the correct NVTX headers. target_compile_definitions(CUDA::nvToolsExt INTERFACE TORCH_CUDA_USE_NVTX3) target_link_libraries(CUDA::nvToolsExt INTERFACE CUDA::nvtx3) endif() From d00b6845467238fb3d96bf481e3c802f5c326d68 Mon Sep 17 00:00:00 2001 From: Felix Kaechele Date: Thu, 25 Sep 2025 14:49:49 -0400 Subject: [PATCH 3/3] Inlcude torch in build-system dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4a80e71..11e0694 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ license-files = ["LICENSE"] exclude = ["**/.mypy_cache/**", "**/build/**", "**/.vscode/**"] [build-system] -requires = ["scikit-build-core>=0.10", "pybind11>=2.10", "cmake", "ninja"] +requires = ["scikit-build-core>=0.10", "pybind11>=2.10", "cmake", "ninja", "torch"] build-backend = "scikit_build_core.build" [tool.isort]