diff --git a/Code/IO/Config.cs b/Code/IO/Config.cs index 54b032b..c771c6c 100644 --- a/Code/IO/Config.cs +++ b/Code/IO/Config.cs @@ -274,7 +274,7 @@ namespace Flowframes.IO if (key == Key.uhdThresh) return WriteDefault(key, "1600"); if (key == Key.torchGpus) return WriteDefault(key, "0"); if (key == Key.ncnnGpus) return WriteDefault(key, "0"); - if (key == Key.ncnnThreads) return WriteDefault(key, "1"); + if (key == Key.ncnnThreads) return WriteDefault(key, "4"); if (key == Key.dainNcnnTilesize) return WriteDefault(key, "768"); // Debug / Other / Experimental if (key == Key.ffEncPreset) return WriteDefault(key, "fast"); diff --git a/Code/Os/AiProcess.cs b/Code/Os/AiProcess.cs index 9ad6f73..607770e 100644 --- a/Code/Os/AiProcess.cs +++ b/Code/Os/AiProcess.cs @@ -318,7 +318,7 @@ namespace Flowframes.Os string ttaStr = Config.GetBool(Config.Key.rifeNcnnUseTta, false) ? "-x" : ""; rifeNcnn.StartInfo.Arguments = $"{OsUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnn.PkgDir).Wrap()} & rife-ncnn-vulkan.exe " + - $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} {frames} -m {mdl.ToLowerInvariant()} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {NcnnUtils.GetNcnnPattern()} -j {NcnnUtils.GetNcnnThreads()}"; + $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} {frames} -m {mdl.ToLowerInvariant()} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {NcnnUtils.GetNcnnPattern()} -j {NcnnUtils.GetNcnnThreads(Implementations.rifeNcnn)}"; Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true); @@ -573,7 +573,7 @@ namespace Flowframes.Os string ttaStr = ""; // Config.GetBool(Config.Key.rifeNcnnUseTta, false) ? "-x" : ""; ifrnetNcnn.StartInfo.Arguments = $"{OsUtils.GetCmdArg()} cd /D {Path.Combine(Paths.GetPkgPath(), Implementations.ifrnetNcnn.PkgDir).Wrap()} & ifrnet-ncnn-vulkan.exe " + - $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {NcnnUtils.GetNcnnPattern()} -j {NcnnUtils.GetNcnnThreads()}"; + $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl} {ttaStr} {uhdStr} -g {Config.Get(Config.Key.ncnnGpus)} -f {NcnnUtils.GetNcnnPattern()} -j {NcnnUtils.GetNcnnThreads(Implementations.ifrnetNcnn)}"; Logger.Log("cmd.exe " + ifrnetNcnn.StartInfo.Arguments, true); diff --git a/Code/Utilities/NcnnUtils.cs b/Code/Utilities/NcnnUtils.cs index e1d125b..a57dbcb 100644 --- a/Code/Utilities/NcnnUtils.cs +++ b/Code/Utilities/NcnnUtils.cs @@ -39,7 +39,7 @@ namespace Flowframes.Utilities public static async Task GetRifeNcnnGpuThreads(Size res, int gpuId, AI ai) { - int threads = 8; + int threads = Config.GetInt(Config.Key.ncnnThreads); //if (res.Width * res.Height > 2560 * 1440) threads = 4; // if (res.Width * res.Height > 3840 * 2160) threads = 1; @@ -74,14 +74,14 @@ namespace Flowframes.Utilities return tilesizeStr; } - public static string GetNcnnThreads(bool forceSingleThread = false) + public static async Task GetNcnnThreads(AI ai) { int gpusAmount = Config.Get(Config.Key.ncnnGpus).Split(',').Length; - int procThreads = Config.GetInt(Config.Key.ncnnThreads); - string progThreadsStr = $"{procThreads}"; + int threads = await GetRifeNcnnGpuThreads(new Size(), Config.Get(Config.Key.ncnnGpus).Split(',')[0].GetInt(), ai); + string progThreadsStr = $"{threads}"; for (int i = 1; i < gpusAmount; i++) - progThreadsStr += $",{procThreads}"; + progThreadsStr += $",{threads}"; return $"{(forceSingleThread ? 1 : (Interpolate.currentlyUsingAutoEnc ? 2 : 4))}:{progThreadsStr}:4"; // Read threads: 1 for singlethreaded, 2 for autoenc, 4 if order is irrelevant }