Added option to stop all GPU apps before setting Eco

This commit is contained in:
Serge
2023-05-29 12:16:19 +02:00
parent 83a2d1dc9f
commit 42cc1bdb98
6 changed files with 100 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
using NvAPIWrapper.GPU;
using NvAPIWrapper;
using NvAPIWrapper.GPU;
using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Delegates;
using NvAPIWrapper.Native.GPU;
@@ -35,8 +36,7 @@ public class NvidiaGpuControl : IGpuControl
public int? GetCurrentTemperature()
{
if (!IsValid)
return null;
if (!IsValid) return null;
PhysicalGPU internalGpu = _internalGpu!;
IThermalSensor? gpuSensor =
@@ -50,6 +50,38 @@ public class NvidiaGpuControl : IGpuControl
{
}
public void KillGPUApps()
{
if (!IsValid) return;
PhysicalGPU internalGpu = _internalGpu!;
try
{
Process[] processes = internalGpu.GetActiveApplications();
foreach (Process process in processes)
{
try
{
process?.Kill();
Logger.WriteLine("Stopped: " + process.ProcessName);
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
}
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
//NVIDIA.RestartDisplayDriver();
}
public int GetClocks(out int core, out int memory)
{