Fix for CUDA 12 nvtx3 library detection - #26
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses CUDA 12 compatibility issues by implementing a workaround for PyTorch's NVTX library detection. The fix creates an alias from the legacy CUDA::nvToolsExt target to the newer CUDA::nvtx3 target when using CUDA 12 or later, ensuring PyTorch can properly link against the NVTX profiling library.
- Adds version check for CUDA compiler version 12 and above
- Creates
CUDA::nvToolsExtinterface target as alias toCUDA::nvtx3when needed - Sets
TORCH_CUDA_USE_NVTX3compile definition to enable PyTorch NVTX3 support
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
PyTorch's CMake config falls back to the legacy CUDA::nvToolsExt target because its bundled nvtx3 headers are not shipped in wheels. CUDA 12 dropped the legacy NVTX library from the default toolkit installation, so on such systems the generate step fails with "target CUDA::nvToolsExt not found" (#23, #25). Define the missing target as an alias of the header-only CUDA::nvtx3 target from FindCUDAToolkit, with the TORCH_CUDA_USE_NVTX3 definition PyTorch expects. The block is guarded so it is a no-op when the legacy NVTX library is installed, when nvtx3 is unavailable, or on CUDA < 12. Verified the branching with a mocked CMake project for all four cases. Ported from the CMake part of PR #26 by @kaechele; the accompanying pyproject.toml change is intentionally not taken (see #30 / #33). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Lvzircq8GvNij9VCm8tZc
|
Thanks for this fix. The CMake part is now on master as d4bbc5c, with an additional guard so that it only activates when CUDA::nvToolsExt is missing and CUDA::nvtx3 exists; you are credited in the commit message. The pyproject.toml change was intentionally not taken: since #33, torch is deliberately not a build requirement and the documented install uses --no-build-isolation. Closing in favor of the ported commit. |
This should fix #25 #24 #23
Fix inspired by https://discuss.pytorch.org/t/failed-to-find-nvtoolsext/179635/13