jcbritobr / nvml-csharp

Nvml( nvidia monitoring library) wrapper for c#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The nvidia monitoring library wrapper written in c#. Please, read the documentation for better understand what is nvml.

  • Example on how to get running processes list
try
{
    NvGpu.NvmlInitV2();
    var device = IntPtr.Zero;
    device = NvGpu.NvmlDeviceGetHandleByIndex(0);
    var (list, count) = NvGpu.NvmlDeviceGetComputeRunningProcesses(device);
    NvGpu.NvmlShutdown();
}
catch (Exception e)
{
    Assert.Fail(e.ToString());
}
  • Example on how to retrieve gpu temperature
try
{
    var device = IntPtr.Zero;
    NvGpu.NvmlInitV2();
    device = NvGpu.NvmlDeviceGetHandleByIndex(0);
    var temperature = NvGpu.NvmlDeviceGetTemperature(device, NvmlTemperatureSensor.NVML_TEMPERATURE_GPU);
    if (!(temperature >= 40 && temperature <= 80))
    {
        Assert.Fail("Cant get temperature.");
    }
    NvGpu.NvmlShutdown();
}
catch (Exception e)
{
    Assert.Fail(e.ToString());
}
  • The wrapper is in working status. Below we have a list of migrated modules
  • Ititialization and Cleanup
  • System Queries
  • Device Queries
  • Unit Queries
  • Unit Commands
  • Device Commands
  • Event Handling Methods
  • Error Reporting
  • Demo Project - There is also a demo project, ported from c language, from original nvml api.

About

Nvml( nvidia monitoring library) wrapper for c#.

License:MIT License


Languages

Language:C# 100.0%