Auto-set NCNN GPU threads default value based on hardware

This commit is contained in:
N00MKRAD
2024-11-14 22:34:26 +01:00
parent 7e043f5273
commit 8a578daac0
3 changed files with 8 additions and 8 deletions

View File

@@ -1188,11 +1188,6 @@
0, 0,
0, 0,
0}); 0});
this.ncnnThreads.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.ncnnThreads.Name = "ncnnThreads"; this.ncnnThreads.Name = "ncnnThreads";
this.ncnnThreads.Size = new System.Drawing.Size(77, 20); this.ncnnThreads.Size = new System.Drawing.Size(77, 20);
this.ncnnThreads.TabIndex = 75; this.ncnnThreads.TabIndex = 75;
@@ -1269,9 +1264,9 @@
this.label44.Location = new System.Drawing.Point(370, 101); this.label44.Location = new System.Drawing.Point(370, 101);
this.label44.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7); this.label44.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label44.Name = "label44"; this.label44.Name = "label44";
this.label44.Size = new System.Drawing.Size(358, 13); this.label44.Size = new System.Drawing.Size(330, 13);
this.label44.TabIndex = 60; this.label44.TabIndex = 60;
this.label44.Text = "Use 1 for small videos, 2 for >1080p, higher values might cause slowdown!"; this.label44.Text = "Higher will cause more GPU/VRAM load but can be faster. 0 = Auto.";
// //
// label43 // label43
// //

View File

@@ -282,7 +282,7 @@ namespace Flowframes.IO
if (key == Key.uhdThresh) return WriteDefault(key, "1600"); if (key == Key.uhdThresh) return WriteDefault(key, "1600");
if (key == Key.torchGpus) return WriteDefault(key, "0"); if (key == Key.torchGpus) return WriteDefault(key, "0");
if (key == Key.ncnnGpus) return WriteDefault(key, "0"); if (key == Key.ncnnGpus) return WriteDefault(key, "0");
if (key == Key.ncnnThreads) return WriteDefault(key, "4"); if (key == Key.ncnnThreads) return WriteDefault(key, "0");
if (key == Key.dainNcnnTilesize) return WriteDefault(key, "768"); if (key == Key.dainNcnnTilesize) return WriteDefault(key, "768");
// Debug / Other / Experimental // Debug / Other / Experimental
if (key == Key.ffEncPreset) return WriteDefault(key, "fast"); if (key == Key.ffEncPreset) return WriteDefault(key, "fast");

View File

@@ -17,6 +17,11 @@ namespace Flowframes.Utilities
int threads = Config.GetInt(Config.Key.ncnnThreads); int threads = Config.GetInt(Config.Key.ncnnThreads);
int maxThreads = VulkanUtils.GetMaxNcnnThreads(gpuId).Clamp(1, 64); int maxThreads = VulkanUtils.GetMaxNcnnThreads(gpuId).Clamp(1, 64);
if(threads == 0)
{
threads = (maxThreads / 2f).RoundToInt().Clamp(1, maxThreads); // Default to half of max threads
}
threads = threads.Clamp(1, maxThreads); // To avoid exceeding the max queue count threads = threads.Clamp(1, maxThreads); // To avoid exceeding the max queue count
Logger.Log($"Using {threads}/{maxThreads} GPU compute threads.", true, false, ai.LogFilename); Logger.Log($"Using {threads}/{maxThreads} GPU compute threads.", true, false, ai.LogFilename);