JT
2 years ago
9 changed files with 93 additions and 70 deletions
@ -0,0 +1,29 @@
|
||||
using System; |
||||
|
||||
namespace StabilityMatrix.Helper; |
||||
|
||||
public static class A1111Helper |
||||
{ |
||||
public static string GetVramOption() |
||||
{ |
||||
var vramGb = HardwareHelper.GetGpuMemoryBytes() / 1024 / 1024 / 1024; |
||||
|
||||
return vramGb switch |
||||
{ |
||||
< 4 => "--lowvram", |
||||
< 8 => "--medvram", |
||||
_ => string.Empty |
||||
}; |
||||
} |
||||
|
||||
public static string GetXformersOption() |
||||
{ |
||||
var gpuName = HardwareHelper.GetGpuChipName(); |
||||
if (gpuName.Contains("NVIDIA", StringComparison.OrdinalIgnoreCase)) |
||||
{ |
||||
return "--xformers"; |
||||
} |
||||
|
||||
return string.Empty; |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
using System; |
||||
using Microsoft.Win32; |
||||
|
||||
namespace StabilityMatrix.Helper; |
||||
|
||||
public class HardwareHelper |
||||
{ |
||||
public static ulong GetGpuMemoryBytes() |
||||
{ |
||||
var registry = Registry.LocalMachine; |
||||
var key = registry.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000", false); |
||||
if (key == null) |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
var vram = key.GetValue("HardwareInformation.qwMemorySize"); |
||||
var vramLong = Convert.ToUInt64(vram); |
||||
return vramLong; |
||||
} |
||||
|
||||
public static string GetGpuChipName() |
||||
{ |
||||
var registry = Registry.LocalMachine; |
||||
var key = registry.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000", false); |
||||
if (key == null) |
||||
{ |
||||
return "Unknown"; |
||||
} |
||||
|
||||
var gpuName = key.GetValue("HardwareInformation.ChipType"); |
||||
return gpuName?.ToString() ?? "Unknown"; |
||||
} |
||||
} |
Loading…
Reference in new issue