Last updated: 2026-06-12
CUDA Runtime
Device
CUDA device wrapper — NVIDIA GPU backend (mirrors src/metal/device.zig).
Owns CUDA context init and capability queries used by the loader, diagnostics, and CUDA inference runtime.
2 exports shown
struct
CudaCapabilities
pub const CudaCapabilities = struct Capability snapshot queried once from the active CUDA device.
struct
CudaDevice
pub const CudaDevice = struct Active CUDA device wrapper plus capability metadata used by the backend.
Methods
10method
CudaDevice.init
pub fn init(allocator: std.mem.Allocator, device_index: u32) !CudaDevice Initialize a specific CUDA device by index and query its capabilities.
method
CudaDevice.initBest
pub fn initBest(allocator: std.mem.Allocator) !CudaDevice Initialize the highest-compute-capability device (prefer 5090 over 4090).
Probes up to 16 device indices, selects the one with the largest compute capability value, then opens a final context on that device via `init`.
method
CudaDevice.deinit
pub fn deinit(self: *CudaDevice) void Destroy the active CUDA context.
method
CudaDevice.totalMemory
pub fn totalMemory(self: *const CudaDevice) u64 Total device memory (VRAM capacity) in bytes.
method
CudaDevice.freeMemory
pub fn freeMemory(self: *const CudaDevice) u64 Currently free device memory in bytes; 0 if the context has been destroyed.
method
CudaDevice.computeCapability
pub fn computeCapability(self: *const CudaDevice) u32 Compute capability encoded as `major*10 + minor` (e.g.
120 = sm_120).
method
CudaDevice.smCount
pub fn smCount(self: *const CudaDevice) u32 Number of streaming multiprocessors (SMs) on the device.
method
CudaDevice.warpSize
pub fn warpSize(self: *const CudaDevice) u32 Threads per warp (32 on all current NVIDIA hardware).
method
CudaDevice.maxSharedMemPerBlock
pub fn maxSharedMemPerBlock(self: *const CudaDevice) u64 Maximum shared memory per block available with opt-in dynamic allocation, in bytes.
method
CudaDevice.name
pub fn name(self: *const CudaDevice, buf: []u8) []const u8 Copy the device name into `buf` and return the NUL-trimmed slice.