Table of Contents

Method GetDeviceFromNumber

Namespace
LMKit.Hardware.Gpu
Assembly
LM-Kit.NET.dll

GetDeviceFromNumber(int)

Retrieves a GpuDeviceInfo object by its deviceNumber from the static Devices list.

public static GpuDeviceInfo GetDeviceFromNumber(int deviceNumber)

Parameters

deviceNumber int

Zero-based index of the device. Negative values are the "no GPU requested" sentinel carried by CPU placements and resolve to null.

Returns

GpuDeviceInfo

The GpuDeviceInfo for the specified deviceNumber, or null if the device number is negative, out of range, or the list is not initialized.

Examples

Accessing a Device By Index

GpuDeviceInfo device = GpuDeviceInfo.GetDeviceFromNumber(0);
if (device != null)
{
    Console.WriteLine($"Device 0: {device.DeviceName}");
}
else
{
    Console.WriteLine("No device found at index 0.");
}
Share