Overclocking logic, added restart-gpu workaround

This commit is contained in:
Serge
2023-05-10 14:06:33 +02:00
parent 27bc7339d8
commit 0142c25929
5 changed files with 149 additions and 90 deletions

View File

@@ -1,5 +1,6 @@
using NvAPIWrapper.GPU;
using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Delegates;
using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.GPU.Structures;
using NvAPIWrapper.Native.Interfaces.GPU;
@@ -74,6 +75,41 @@ public class NvidiaGpuControl : IGpuControl
}
private static void RunCMD(string name, string args)
{
var cmd = new Process();
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.StartInfo.FileName = name;
cmd.StartInfo.Arguments = args;
cmd.Start();
Logger.WriteLine(cmd.StandardOutput.ReadToEnd());
cmd.WaitForExit();
}
public void RestartGPU()
{
if (!IsValid) return;
try
{
PhysicalGPU internalGpu = _internalGpu!;
var pnpDeviceId = internalGpu.BusInformation.PCIIdentifiers.ToString();
Logger.WriteLine("Device ID:"+ pnpDeviceId);
RunCMD("pnputil", $"/disable-device /deviceid \"{pnpDeviceId}\"");
Thread.Sleep(1000);
RunCMD("pnputil", $"/enable-device /deviceid \"{pnpDeviceId}\"");
}
catch (Exception ex )
{
Logger.WriteLine(ex.ToString());
}
}
public int SetClocksFromConfig()
{
int core = Program.config.getConfig("gpu_core");