bindbc-cuda ~main

Static and dynamic D bindings for the NVIDIA CUDA Driver API, compatible with BetterC, @nogc, and nothrow.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

bindbc-cuda

DUB Package License

Static and dynamic D bindings for the NVIDIA CUDA Driver API, compatible with @nogc, nothrow, and -betterC.

Features

  • Dynamic loading — Load nvcuda.dll / libcuda.so at runtime via bindbc-loader.
  • Static linking — Link against the CUDA driver library at compile time.
  • BetterC compatible — Zero D runtime dependency.
  • Versioned symbols — Binds to the modern _v2 Driver API entry points.
  • Multi-version support — Covers CUDA 10.0 through 12.4.

Adding to your project

dub.json

"dependencies": {
    "bindbc-cuda": "~>1.0"
}

dub.sdl

dependency "bindbc-cuda" version="~>1.0"

Selecting a CUDA version

Pass the appropriate version identifier to target a specific CUDA release:

"versions": ["CUDA_120"]

The default (no version set) targets CUDA 10.0.

Static binding

To link against the CUDA driver library at compile time instead of loading it dynamically at runtime:

"subConfigurations": {
    "bindbc-cuda": "static"
}

Configurations

ConfigurationDescription
dynamicDynamic binding via bindbc-loader (default)
dynamicBCDynamic binding with -betterC
staticStatic (link-time) binding
staticBCStatic binding with -betterC

Usage

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);
}

Folder structure

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

License

Distributed under the Boost Software License, Version 1.0.

Authors:
  • Nikhil
Dependencies:
none
Versions:
0.1.1 2026-May-14
0.1.0 2026-May-08
~main 2026-May-14
Show all 3 versions
Download Stats:
  • 1 downloads today

  • 4 downloads this week

  • 11 downloads this month

  • 11 downloads total

Score:
0.3
Short URL:
bindbc-cuda.dub.pm