Table of Contents

Class CudaDeviceDetector

Namespace
DotCompute.Backends.CUDA.Discovery
Assembly
DotCompute.Backends.CUDA.dll

Provides device discovery capabilities for CUDA-capable GPUs. Implements the hexagonal architecture pattern for device discovery port.

public sealed class CudaDeviceDetector : IDeviceDiscoveryPort
Inheritance
CudaDeviceDetector
Implements
Inherited Members

Constructors

CudaDeviceDetector(ILogger<CudaDeviceDetector>?)

Initializes a new instance of the CudaDeviceDetector class.

public CudaDeviceDetector(ILogger<CudaDeviceDetector>? logger = null)

Parameters

logger ILogger<CudaDeviceDetector>

Optional logger instance.

Properties

BackendType

Gets the backend type.

public BackendType BackendType { get; }

Property Value

BackendType

Methods

Detect(int, ILogger<CudaDevice>?)

Detects a specific CUDA device by ID.

public static CudaDevice? Detect(int deviceId, ILogger<CudaDevice>? logger = null)

Parameters

deviceId int

The device ID to detect.

logger ILogger<CudaDevice>

Optional logger instance.

Returns

CudaDevice

A CudaDevice instance if successful, null otherwise.

DetectAll(ILogger?)

Detects all available CUDA devices on the system.

public static IEnumerable<CudaDevice> DetectAll(ILogger? logger = null)

Parameters

logger ILogger

Optional logger instance.

Returns

IEnumerable<CudaDevice>

An enumerable of detected CudaDevice instances.

DiscoverDevicesAsync(CancellationToken)

Discovers all available devices.

public ValueTask<IReadOnlyList<DiscoveredDevice>> DiscoverDevicesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<DiscoveredDevice>>

List of discovered devices.

GetCapabilitiesAsync(string, CancellationToken)

Gets detailed capabilities for a specific device.

public ValueTask<DeviceCapabilities> GetCapabilitiesAsync(string deviceId, CancellationToken cancellationToken = default)

Parameters

deviceId string

The device identifier.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<DeviceCapabilities>

Device capabilities.

GetDeviceCount()

Gets the number of available CUDA devices.

public static int GetDeviceCount()

Returns

int

The device count, or 0 if detection fails.

IsAvailable()

Checks if any CUDA devices are available.

public static bool IsAvailable()

Returns

bool

True if at least one CUDA device is available.

IsDeviceAvailable(string)

Checks if a specific device is available.

public bool IsDeviceAvailable(string deviceId)

Parameters

deviceId string

The device identifier.

Returns

bool

True if the device is available.