Static and dynamic D bindings for the NVIDIA CUDA Driver API,
compatible with @nogc, nothrow, and -betterC.
- Dynamic loading — Load
nvcuda.dll/libcuda.soat runtime viabindbc-loader. - Static linking — Link against the CUDA driver library at compile time.
- BetterC compatible — Zero D runtime dependency.
- Versioned symbols — Binds to the modern
_v2Driver API entry points. - Multi-version support — Covers CUDA 10.0 through 12.4.
"dependencies": {
"bindbc-cuda": "~>1.0"
}dependency "bindbc-cuda" version="~>1.0"
Pass the appropriate version identifier to target a specific CUDA release:
"versions": ["CUDA_120"]The default (no version set) targets CUDA 10.0.
To link against the CUDA driver library at compile time instead of loading it dynamically at runtime:
"subConfigurations": {
"bindbc-cuda": "static"
}| Configuration | Description |
|---|---|
dynamic |
Dynamic binding via bindbc-loader (default) |
dynamicBC |
Dynamic binding with -betterC |
static |
Static (link-time) binding |
staticBC |
Static binding with -betterC |
import bindbc.cuda;
void main() {
auto ret = loadCUDA();
if(ret == CUDASupport.noLibrary) {
// CUDA driver library not found on this system.
return;
}
if(ret == CUDASupport.badLibrary) {
// Library found but one or more symbols failed to bind.
return;
}
// Driver API is ready.
cuInit(0);
int count;
cuDeviceGetCount(&count);
CUdevice dev;
cuDeviceGet(&dev, 0);
char[256] name;
cuDeviceGetName(name.ptr, cast(int)name.length, dev);
}bindbc-cuda/
├── dub.json
├── README.md
└── source/
└── bindbc/
└── cuda/
├── package.d — Public import aggregator
├── config.d — Version selection, staticBinding flag
├── types.d — Opaque handles, enums, flags
└── binddynamic.d — Dynamic symbol loading via bindbc-loader
Distributed under the Boost Software License, Version 1.0.