30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public static class NvmlWrapper
|
|
{
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlInit_v2")]
|
|
public static extern int NvmlInit();
|
|
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlShutdown")]
|
|
public static extern int NvmlShutdown();
|
|
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlDeviceGetHandleByIndex_v2")]
|
|
public static extern int NvmlDeviceGetHandleByIndex(int index, out IntPtr device);
|
|
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlDeviceGetUtilizationRates")]
|
|
public static extern int NvmlDeviceGetUtilizationRates(IntPtr device, out NvmlUtilization utilization);
|
|
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlDeviceGetTemperature")]
|
|
public static extern int NvmlDeviceGetTemperature(IntPtr device, uint sensorType, out uint temp);
|
|
|
|
[DllImport("nvml.dll", EntryPoint = "nvmlDeviceGetFanSpeed")]
|
|
public static extern int NvmlDeviceGetFanSpeed(IntPtr device, out uint speed);
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct NvmlUtilization
|
|
{
|
|
public uint Gpu;
|
|
public uint Memory;
|
|
}
|
|
} |