Skip to content

Fix for CUDA 12 nvtx3 library detection - #26

Closed
kaechele wants to merge 3 commits into
tatsy:masterfrom
kaechele:master
Closed

Fix for CUDA 12 nvtx3 library detection#26
kaechele wants to merge 3 commits into
tatsy:masterfrom
kaechele:master

Conversation

@kaechele

@kaechele kaechele commented Aug 6, 2025

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings August 6, 2025 15:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::nvToolsExt interface target as alias to CUDA::nvtx3 when needed
  • Sets TORCH_CUDA_USE_NVTX3 compile definition to enable PyTorch NVTX3 support

Comment thread CMakeLists.txt Outdated
kaechele and others added 2 commits September 14, 2025 14:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tatsy pushed a commit that referenced this pull request Sep 10, 2026
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
@tatsy

tatsy commented Sep 10, 2026

Copy link
Copy Markdown
Owner

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.

@tatsy tatsy closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to install on Windows: Cannot build wheel for torchmcubes

3 participants