Skip to content

Supply CUDA math libs via CUDAToolkit imported targets - #100

Open
joshkamm wants to merge 1 commit into
mainfrom
claude/slater-gpu-issue-98-a65411
Open

Supply CUDA math libs via CUDAToolkit imported targets#100
joshkamm wants to merge 1 commit into
mainfrom
claude/slater-gpu-issue-98-a65411

Conversation

@joshkamm

@joshkamm joshkamm commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fixes #98. Closes #93.

Problem

pixi-build-cmake 0.3.12+ absorbed rattler-build 0.62.0's strict build-environment isolation: the build no longer inherits the developer's shell env (PATH stays on the forwarding allowlist; CPATH does not). nvc++ is still found, but the NVHPC module's math_libs/include no longer reaches it, so every USE_ACC translation unit fails on #include <cublas_v2.h>. The group was shielded by the <=0.3.8 backend cap until #97 bumped it to <=0.4.2 (2026-07-01) — which is why builds "the same as before" suddenly broke. Full evidence trail in #98 (comment).

Fix

Make the build supply the CUDA math libraries itself instead of relying on ambient CPATH:

  • find_package(CUDAToolkit REQUIRED) under USE_ACC (top-level)
  • target_link_libraries(SlaterGPU PUBLIC CUDA::cublas CUDA::cusolver) — PUBLIC because include/cuda_util.h includes the cuBLAS/cuSolver headers when USE_ACC, so dependents (io, sgpu.exe, downstream consumers like ZEST) need the headers and libraries too; they now inherit both transitively
  • examples/: drop the removed-in-CMake-4 FindCUDA module, enable_language(CUDA), and the hand-rolled ${CUDA_TOOLKIT_ROOT_DIR}/../../math_libs/lib64/libcublas.so paths (FindCUDAToolkit understands the NVHPC layout natively); keep CUDA::cudart
  • SlaterGPUConfig.cmake.in: replace the deprecated find_package(CUDA QUIET) / enable_language(CUDA) block (the CMP0146 warning from Replace deprecated FindCUDA module with find_package(CUDAToolkit) in Config.cmake.in #93) with find_dependency(CUDAToolkit REQUIRED) gated on the exported USE_ACC setting

Verification

Cold pixi build (fresh cache, wiped .pixi) pinned to backend ==0.3.14 (sanitized env) on Perlmutter, NVHPC 25.5:

Notes for review

  • The CMake ≥4.1 warning at the top of CMakeLists.txt (from Fix CI after broken from new cmake release #50) referenced CUDART_LIBRARY errors produced by the old FindCUDA/find_library code in examples/, which this PR removes — the warning may now be obsolete, but I left it for a separate decision (the monthly latest-pixi CI run can re-evaluate it).
  • Consumers (ZEST, XCtera) need no changes: the exported SlaterGPUTargets.cmake now carries CUDA::cublas/CUDA::cusolver in the interface, resolved by the Config file's find_dependency(CUDAToolkit). Their lock hashes will need the usual bump after merge.

🤖 Generated with Claude Code

pixi-build-cmake >=0.3.12 (via rattler-build 0.62's strict env isolation)
no longer forwards CPATH from the developer's shell into the build, so
nvc++ lost the NVHPC module's math_libs include path and every GPU
translation unit failed on #include <cublas_v2.h> (#98).

Make the build self-sufficient instead of relying on ambient CPATH:

- find_package(CUDAToolkit) when USE_ACC, and link CUDA::cublas /
  CUDA::cusolver PUBLIC on SlaterGPU so io, sgpu.exe, and downstream
  consumers inherit both headers and libraries transitively
- Replace the removed FindCUDA module and hand-rolled NVHPC math_libs
  library paths in examples/ with CUDA::cudart
- Replace deprecated find_package(CUDA) in SlaterGPUConfig.cmake.in with
  find_dependency(CUDAToolkit) gated on the USE_ACC build setting (#93)

Verified with a cold pixi build pinned to backend 0.3.14 (sanitized env):
CUDAToolkit 12.9.41 is discovered from the NVHPC layout via PATH alone
and all previously failing cuBLAS/cuSolver TUs compile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant