Skip to content

Fix: cudnn-sys Windows build include paths#366

Open
CharryWu wants to merge 3 commits intoRust-GPU:mainfrom
CharryWu:fix-cudnn-windows-cudnn-paths
Open

Fix: cudnn-sys Windows build include paths#366
CharryWu wants to merge 3 commits intoRust-GPU:mainfrom
CharryWu:fix-cudnn-windows-cudnn-paths

Conversation

@CharryWu
Copy link

Summary

  • Extend cudnn-sys Windows cuDNN detection to support modern CUDA Toolkit include paths under C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\….
  • Add dynamic discovery of vX.Y directories (e.g. v10.6, v12.1, v13.0) under both the legacy cuDNN root and the CUDA Toolkit root.
  • Add unit tests that validate the vX.Y directory-name matching logic and that multiple Windows CUDA/cuDNN versions are discovered correctly.

This change is related to my earlier comment on issue #204, where cuDNN headers could not be found when using newer CUDA/cuDNN layouts.

Details

  • Windows include path discovery

    • Previously, Windows builds only checked:
      • C:/Program Files/NVIDIA/CUDNN/v9.x/include
      • C:/Program Files/NVIDIA/CUDNN/v8.x/include
    • Now, for Windows:
      • We keep the above legacy paths as explicit fallbacks.
      • We dynamically enumerate directories under:
        • C:/Program Files/NVIDIA/CUDNN
        • C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA
      • For each of these bases, we treat any subdirectory whose name matches vX.Y[.Z…] (all numeric components) as a candidate version and add <base>/vX.Y/include to the search list.
      • The first directory that contains both cudnn.h and cudnn_version.h is selected.
  • Helper functions

    • Introduced CudnnSdk::is_vxy_dir_name to encapsulate the vX.Y pattern check.
    • Introduced CudnnSdk::collect_windows_cudnn_include_paths to gather include paths from one or more base directories.
  • Tests

    • is_vxy_dir_name_accepts_valid_versions and is_vxy_dir_name_rejects_invalid_versions ensure the matcher behaves correctly for valid/invalid names.
    • collect_windows_cudnn_include_paths_discovers_multiple_versions creates a temporary directory structure with:
      • v10.6/include, v12.1/include, v13.0/include (with stub cudnn.h and cudnn_version.h),
      • plus some non-version directories,
        and asserts that only the valid vX.Y/include directories are discovered.

Rationale

  • Newer CUDA Toolkit + cuDNN combinations commonly install under C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include and similar, which the previous hard-coded paths did not cover.
  • Allowing discovery of any vX.Y directory under the known NVIDIA roots makes cudnn-sys more robust across:
    • different major/minor CUDA versions,
    • users who keep multiple toolkits installed side-by-side,
    • future versions where only the numeric components change.

Testing

  • cargo check -p cudnn-sys on Windows with:
    • CUDNN_INCLUDE_DIR unset,
    • real v13.0 CUDA Toolkit install,
    • additional copied directories v12.1, v10.6 under C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA.
  • cargo test -p cudnn-sys (Windows):
    • All new unit tests in crates/cudnn-sys/build/cudnn_sdk.rs pass.

Attribution

This bugfix was implemented with the help of Cursor.

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.

1 participant