MultiGpuHelper 1.1.0
dotnet add package MultiGpuHelper --version 1.1.0
NuGet\Install-Package MultiGpuHelper -Version 1.1.0
<PackageReference Include="MultiGpuHelper" Version="1.1.0" />
<PackageVersion Include="MultiGpuHelper" Version="1.1.0" />
<PackageReference Include="MultiGpuHelper" />
paket add MultiGpuHelper --version 1.1.0
#r "nuget: MultiGpuHelper, 1.1.0"
#:package MultiGpuHelper@1.1.0
#addin nuget:?package=MultiGpuHelper&version=1.1.0
#tool nuget:?package=MultiGpuHelper&version=1.1.0
MultiGpuHelper
MultiGpuHelper is a .NET Standard 2.0 library for discovering GPU adapters, selecting a device, and limiting concurrent GPU work. Discovery is best-effort: each backend reports only data available from its underlying operating-system, command-line, or driver API.
What it does
- Discovers devices through
nvidia-smi, the CUDA Driver API, ROCmrocminfo, or Windows WMI. - Represents discovery results as immutable
GpuDeviceInfosnapshots. - Selects devices using first-available, most-free-memory, round-robin, or specific-device policies.
- Dispatches callbacks with per-device concurrency limits and soft VRAM reservations.
What it does not do
The library does not execute CUDA, ROCm, DirectX, or machine-learning kernels. It does not allocate physical VRAM, guarantee that reported free memory remains current, or merge records from different discovery backends.
Supported platforms and backends
| Backend | Mechanism | Platform requirement | Memory data |
|---|---|---|---|
NvidiaBackend |
nvidia-smi |
NVIDIA tools on PATH |
Total and free VRAM when the command reports both |
CudaBackend |
CUDA Driver API | Windows NVIDIA driver | Total VRAM; free VRAM unknown |
RocmBackend |
rocminfo |
ROCm tools on PATH |
Free VRAM unknown |
WmiBackend |
Win32_VideoController |
Windows with WMI | VRAM intentionally unknown |
ROCm behavior has unit coverage but has not been maintainer-verified on AMD hardware. See backend details.
Installation
dotnet add package MultiGpuHelper --version 1.1.0
Quick start
using MultiGpuHelper.Backends;
using MultiGpuHelper.Models;
using MultiGpuHelper.Selection;
var backend = new NvidiaBackend();
var devices = await backend.DetectDevicesAsync();
var selection = new GpuSelectionEngine().SelectDevice(
devices,
GpuPolicy.MostFreeMemory);
if (selection.IsSuccess)
Console.WriteLine($"Selected {selection.SelectedDevice.DeviceName}");
else
Console.WriteLine(selection.Reason);
Device discovery
Backends implement IGpuBackend. An empty result means the backend was unavailable, failed, or detected no devices; use IsAvailableAsync when that distinction matters. GpuDeviceInfo.Backend identifies the discovery mechanism and Vendor identifies the hardware vendor.
Device selection
GpuSelectionEngine accepts immutable discovery snapshots. FirstAvailable, MostFreeMemory, RoundRobin, and SpecificDevice have unique values and behavior. Unknown memory is represented by GpuMemoryInfo.State, not by treating zero as measured free VRAM.
Dispatching work
GpuDispatcher operates on mutable GpuDevice scheduling registrations managed by GpuManager. Its cancellation-aware overload accepts Func<int, CancellationToken, Task<T>>. GpuWorkItem.TimeoutMs covers waiting and callback execution, but callback cancellation is cooperative.
Error handling
Selection failures from GpuManager throw GpuSelectionException; budget rejection throws GpuBudgetExceededException; caller cancellation and timeouts surface as OperationCanceledException. Callback exceptions propagate unchanged. See error handling.
Thread safety
Concurrent manager selection and dispatcher calls are synchronized. Objects returned by GpuManager.Devices remain mutable; do not change device configuration while work is being dispatched. See threading semantics.
Limitations
- Device IDs are backend-local ordinals, not persistent physical identifiers.
- Results from multiple backends are not deduplicated.
- WMI VRAM is unknown because
AdapterRAMis not authoritative for modern adapters. - Soft VRAM reservations do not allocate or measure hardware memory.
- Hardware-dependent discovery varies with installed tools, drivers, and permissions.
Documentation
Contributing / Issues
Bug reports should include MultiGpuHelper version, OS, .NET version, GPU model, driver/runtime version, backend, a minimal reproduction, and the exception with stack trace. Use the GitHub issue tracker.
License
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Management (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.