Skip to content

GPU build fails: nvc++ can't find cublas_v2.h / cusolverDn.h (NVHPC env not forwarded to pixi build sandbox) #98

Description

@joshkamm

Summary

Building slatergpu as a pixi source dependency (git-main, currently a7f971f) fails to compile the GPU library because nvc++ cannot find cublas_v2.h / cusolverDn.h:

"…/include/cuda_util.h", line 11: catastrophic error: cannot open source file "cublas_v2.h"
  #include <cublas_v2.h>
                        ^
1 catastrophic error detected in the compilation of "…/src/integrals/cuda_util.cpp".
Compilation terminated.

Every GPU-path translation unit (cuda_util.cpp, scf_util.cpp, integrals*.cpp, …) fails the same way. include/cuda_util.h:11 pulls in <cublas_v2.h> / <cusolverDn.h> under #if USE_ACC.

Reported by multiple group members recently while building "the same way as before" — consistent with the umbrella in #95 (git-main build fails, local-path workaround). This issue documents the cuBLAS/cuSolver facet with a fully-traced root cause.

Root cause — environment, not the repo

nvc++ locates the CUDA math-library headers via the NVHPC module environment (module load nvhpc sets CPATH=…/math_libs/include). The pixi build sandbox runs nvc++ with that environment stripped, so the headers are unreachable. Confirmed both directions on athena (NVHPC 25.5, nvc++ 25.5-0; pixi 0.70.2):

Condition cuda_util.cpp compile
Interactive shell, nvhpc module loaded (CPATH set) ✅ compiles
Env stripped (simulates pixi sandbox) cannot open source file "cublas_v2.h"
Env stripped + CPATH=…/math_libs/include re-added ✅ compiles
Env stripped + -cudalib=cublas,cusolver ✅ compiles
Env stripped + -I …/math_libs/include ✅ compiles

The header itself is present (…/nvidia_hpc_sdk/Linux_x86_64/25.5/math_libs/include/cublas_v2.h); the build just isn't told where to look.

Why a git bisect of the repos won't isolate it

The in-repo wiring hasn't changed: the <cublas_v2.h> include is long-standing, and SlaterGPU has never passed -cudalib (git log -S cudalib is empty). What flipped is whether the pixi build sandbox forwards the NVHPC/CPATH environment to nvc++ — i.e. the pixi / pixi-build-cmake toolchain, not SlaterGPU source. The useful bisect is to hold both repos fixed and vary the pixi version (0.70 ↔ 0.71), tying in with #96.

Proposed fix (repo-side, environment-independent)

Make the GPU build supply the CUDA math-lib headers itself, so it no longer depends on every developer's shell having CPATH set. Options (both validated under the stripped env above):

  1. Add -cudalib=cublas,cusolver to the GPU target_compile_options (nvc++ then provides both include + link). Minimal, nvc++-native.
  2. find_package(CUDAToolkit) and link CUDA::cublas / CUDA::cusolver — also closes Replace deprecated FindCUDA module with find_package(CUDAToolkit) in Config.cmake.in #93 (FindCUDA → CUDAToolkit modernization).

Environment

  • athena; NVHPC SDK 25.5 (nvc++ 25.5-0), CUDA math_libs 12.9
  • pixi 0.70.2, pixi-build-cmake backend, USE_ACC=ON (default GPU build)
  • SlaterGPU git-main @ a7f971f

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions