Skip to content

Commit

Permalink
add nvidia gpu memory usage percentage
Browse files Browse the repository at this point in the history
Adds a sensor to the "Load" category to show GPU memory usage
as a percentage for Nvidia GPUs
  • Loading branch information
ntoff committed Nov 24, 2022
1 parent 777b78a commit aab811f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LibreHardwareMonitorLib/Hardware/Gpu/NvidiaGpu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal sealed class NvidiaGpu : GenericGpu
private readonly Sensor _memoryJunctionTemperature;
private readonly Sensor _memoryTotal;
private readonly Sensor _memoryUsed;
private readonly Sensor _memoryLoad;
private readonly NvidiaML.NvmlDevice? _nvmlDevice;
private readonly Sensor _pcieThroughputRx;
private readonly Sensor _pcieThroughputTx;
Expand Down Expand Up @@ -420,6 +421,7 @@ public NvidiaGpu(int adapterIndex, NvApi.NvPhysicalGpuHandle handle, NvApi.NvDis
_memoryFree = new Sensor("GPU Memory Free", 0, SensorType.SmallData, this, settings);
_memoryUsed = new Sensor("GPU Memory Used", 1, SensorType.SmallData, this, settings);
_memoryTotal = new Sensor("GPU Memory Total", 2, SensorType.SmallData, this, settings);
_memoryLoad = new Sensor("GPU Memory Used", 3, SensorType.Load, this, settings);

Update();
}
Expand Down Expand Up @@ -611,6 +613,9 @@ public override void Update()

_memoryUsed.Value = (total - free) / 1024;
ActivateSensor(_memoryUsed);

_memoryLoad.Value = ((float)(total - free) / total) * 100;
ActivateSensor(_memoryLoad);
}
}

Expand Down

0 comments on commit aab811f

Please sign in to comment.