Drop CUDA::cuda_driver link so mbpt.exe launches on CPU-only nodes - #18
Conversation
green-gpu makes no CUDA driver API calls: the only cu* symbols in the source are the inline cuComplex.h helpers (cuCadd/cuCmul/cuCreal/...), which come from a header, not libcuda. Everything else uses the CUDA runtime API, cuBLAS, and cuSolver. Linking CUDA::cuda_driver (libcuda.so.1) therefore added a spurious hard DT_NEEDED on the NVIDIA driver library. Since accel-lib/gpu are static and get absorbed into mbpt.exe when green-gpu is used as a CUSTOM_KERNEL, the resulting mbpt.exe failed to even launch on CPU-only nodes with "libcuda.so.1: cannot open shared object file" -- including for pure CPU runs that never touch the GPU. Dropping the link removes the startup dependency; the shared CUDA runtime loads the driver lazily on the first CUDA call, so one binary starts on both CPU-only and GPU nodes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The only remaining CUDA driver-API call was cuDeviceGetAttribute with CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE (added for CUDA 13 compatibility after cudaDeviceProp::memoryClockRate was removed). That single call is what forced accel-lib/gpu to link libcuda, defeating the point of dropping CUDA::cuda_driver. NVIDIA's documented CUDA 13 replacement for the removed memoryClockRate field is the runtime API cudaDeviceGetAttribute(cudaDevAttrMemoryClockRate), which returns the same kHz value, is available across CUDA versions, and links only against libcudart. Switch to it so no driver-API symbols remain and the binary needs no libcuda at startup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Good catch on Fixed in 27b64b3 by switching to the runtime-API equivalent |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
=======================================
Coverage 96.71% 96.71%
=======================================
Files 13 13
Lines 852 852
=======================================
Hits 824 824
Misses 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR removes an unnecessary hard link dependency on the CUDA driver library (libcuda.so.1) so CUDA-enabled binaries that embed green-gpu can still launch on CPU-only nodes (and only require the NVIDIA driver if GPU code actually executes).
Changes:
- Drop
CUDA::cuda_driverfromaccel-libandgpulink lines to avoid aDT_NEEDEDentry forlibcuda.so.1at program start. - Replace the one CUDA driver API usage (
cuDeviceGetAttribute) with the CUDA runtime API equivalent (cudaDeviceGetAttribute) in device-info printing code.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/cuda_check.cpp | Removes the lone CUDA driver API call by switching to the runtime attribute query API. |
| src/CMakeLists.txt | Removes CUDA::cuda_driver from library linkage to prevent startup-time dependency on libcuda.so.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
egull
left a comment
There was a problem hiding this comment.
Looks good and is actually quite a useful convenience feature. I'm approving and merging.
Problem
When
green-mbpt'smbpt.exeis built withgreen-gpuas aCUSTOM_KERNEL, the resulting binary fails to even launch on CPU-only nodes with:This happens even for pure-CPU runs that never touch the GPU, which prevents shipping a single binary usable on both CPU-only and GPU nodes.
Root cause
src/CMakeLists.txtlinksCUDA::cuda_driver(i.e.libcuda.so.1, the NVIDIA driver library, which only exists on nodes with the GPU driver installed). But green-gpu makes no CUDA driver API calls — the onlycu*symbols anywhere in the source are the inlinecuComplex.hhelpers (cuCadd/cuCmul/cuCreal/…), which come from a header, not fromlibcuda. Everything else is CUDA runtime API + cuBLAS + cuSolver.Because
accel-lib/gpuare static libraries absorbed intombpt.exe, that spurious link put a hardDT_NEEDEDonlibcuda.so.1into the final executable, so the dynamic loader demanded the driver at startup.Fix
Remove
CUDA::cuda_driverfrom both link lines. The shared CUDA runtime loads the driver lazily on the first CUDA call, so the binary starts on CPU-only nodes and only needs the driver if GPU code actually runs.Verification
Confirmed by the reporter that a CUDA-enabled
mbpt.exebuilt against this change launches on CPU-only nodes.🤖 Generated with Claude Code