Move DisablePython around, benchmark NvApi init

This commit is contained in:
N00MKRAD
2024-08-15 11:34:36 +02:00
parent 49a3c87bdf
commit d0a7c0aee4
5 changed files with 15 additions and 11 deletions

View File

@@ -6,8 +6,6 @@ namespace Flowframes.Data
{
class Implementations
{
public static bool DisablePython = false;
public static AI rifeCuda = new AI()
{
Backend = AI.AiBackend.Pytorch,
@@ -84,7 +82,7 @@ namespace Flowframes.Data
{
get
{
bool pytorchAvailable = !DisablePython && Python.IsPytorchReady();
bool pytorchAvailable = !Python.DisablePython && Python.IsPytorchReady();
if (pytorchAvailable)
return NetworksAll;

View File

@@ -54,7 +54,6 @@ namespace Flowframes.Forms.Main
// Main Tab
UiUtils.InitCombox(interpFactorCombox, 0);
UiUtils.InitCombox(outSpeedCombox, 0);
UiUtils.InitCombox(aiModel, 2);
// Video Utils
UiUtils.InitCombox(trimCombox, 0);
@@ -162,11 +161,11 @@ namespace Flowframes.Forms.Main
await Python.CheckCompression();
await StartupChecks.SymlinksCheck();
await StartupChecks.DetectHwEncoders();
}
catch (Exception e)
{
Logger.Log("Non-critical error while performing online checks. See logs for details.");
Logger.Log($"{e.Message}\n{e.StackTrace}", true);
Logger.Log($"Checks Error: {e.Message}\n{e.StackTrace}", true);
}
}

View File

@@ -1,4 +1,5 @@
using NvAPIWrapper;
using Flowframes.MiscUtils;
using NvAPIWrapper;
using NvAPIWrapper.GPU;
using System;
using System.Collections.Generic;
@@ -16,6 +17,7 @@ namespace Flowframes.Os
{
try
{
var sw = new NmkdStopwatch();
NVIDIA.Initialize();
PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();
@@ -31,7 +33,7 @@ namespace Flowframes.Os
string gpuNamesList = string.Join(", ", gpuNames);
Logger.Log($"Initialized Nvidia API. GPU{(gpus.Length > 1 ? "s" : "")}: {gpuNamesList}", true);
Logger.Log($"Initialized Nvidia API in {sw.ElapsedMs} ms. GPU{(gpus.Length > 1 ? "s" : "")}: {gpuNamesList}", true);
}
catch (Exception e)
{

View File

@@ -10,6 +10,8 @@ namespace Flowframes.Os
{
class Python
{
public static bool DisablePython = false;
static bool hasCheckedSysPy = false;
static bool sysPyInstalled = false;
@@ -17,7 +19,7 @@ namespace Flowframes.Os
public static async Task CheckCompression ()
{
if (Implementations.DisablePython || !HasEmbeddedPyFolder() || (Config.Get(Config.Key.compressedPyVersion) == Updater.GetInstalledVer().ToString()))
if (DisablePython || !HasEmbeddedPyFolder() || (Config.Get(Config.Key.compressedPyVersion) == Updater.GetInstalledVer().ToString()))
return;
Program.mainForm.SetWorking(true, false);
@@ -110,6 +112,9 @@ namespace Flowframes.Os
public static bool IsPytorchReady (bool clearCachedValue = false)
{
if (DisablePython)
return false;
if (clearCachedValue)
pytorchReadyCached = null;
@@ -128,7 +133,7 @@ namespace Flowframes.Os
static string GetPytorchVer()
{
if(Implementations.DisablePython)
if(DisablePython)
return "";
try

View File

@@ -52,7 +52,7 @@ namespace Flowframes
var opts = new OptionSet
{
{ "np|no_python", "Disable Python implementations", v => Implementations.DisablePython = v != null },
{ "np|no_python", "Disable Python implementations", v => Python.DisablePython = v != null },
};
try