Increase default NCNN threads, allow more than 3 with NCNN VS

This commit is contained in:
n00mkrad 2023-02-17 22:10:33 +01:00
parent fbee4d8c06
commit c20c1b55ee
3 changed files with 8 additions and 8 deletions

View File

@ -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");

View File

@ -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);

View File

@ -39,7 +39,7 @@ namespace Flowframes.Utilities
public static async Task<int> 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<string> 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
}