Skip to content

fix(cuda-bindings): resolve build failure by checking CUDA_HOME - #17

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
JonatanLindh:fix-cuda13-build
May 12, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
JonatanLindh:fix-cuda13-build

Conversation

@JonatanLindh

Copy link
Copy Markdown
Contributor

Resolves #16

Problem

In environments where CUDA_TOOLKIT_PATH is not explicitly set but standard environment variables like CUDA_HOME are, build.rs silently falls back to /usr/local/cuda. If this directory doesn't exist or contains a different CUDA version, std::fs::read_to_string silently fails.

This causes the build script to skip enabling the cuda_has_cuEventElapsedTime_v2 feature flag, resulting in a cryptic cannot find function compilation error downstream on CUDA 13 (when CUDA_HOME is the correct location).

Changes

  • cuda_toolkit_dir() now checks CUDA_HOME before falling back to /usr/local/cuda`.
  • Added cargo:rerun-if-env-changed=CUDA_HOME
  • Replaced the silent .unwrap_or(false) with a cargo:warning. If the script cannot read cuda.h, it now emits a visible warning during cargo build explaining exactly which path failed.

Checklist

  • I have signed my commits (DCO).
  • Code is formatted with cargo fmt.
  • Checked with cargo clippy.

@JonatanLindh
JonatanLindh force-pushed the fix-cuda13-build branch 2 times, most recently from 506ad99 to ddc6f07 Compare May 11, 2026 12:24
@nihalpasham
nihalpasham self-requested a review May 12, 2026 04:41
@nihalpasham nihalpasham added enhancement New feature or request build-related Build scripts, toolchain discovery, or compilation setup labels May 12, 2026

@nihalpasham nihalpasham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix. Approved as-is

@nihalpasham
nihalpasham merged commit 773d9ce into NVIDIA:main May 12, 2026
16 of 31 checks passed
@JonatanLindh
JonatanLindh deleted the fix-cuda13-build branch May 12, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build.rs does not check CUDA_HOME (only checks CUDA_TOOLKIT_PATH)

2 participants