diff --git a/Code/Form1.cs b/Code/Form1.cs index 64e1bb6..c9aca45 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -35,7 +35,7 @@ namespace Flowframes CheckForIllegalCrossThreadCalls = false; AutoScaleMode = AutoScaleMode.None; - if(!File.Exists(Paths.GetVerPath()) && Paths.GetExeDir().ToLower().Contains("temp")) + if (!File.Exists(Paths.GetVerPath()) && Paths.GetExeDir().ToLower().Contains("temp")) { MessageBox.Show("You seem to be running Flowframes out of an archive.\nPlease extract the whole archive first!", "Error"); IOUtils.TryDeleteIfExists(Paths.GetDataPath()); @@ -54,6 +54,7 @@ namespace Flowframes Program.mainForm = this; Logger.textbox = logBox; + NvApi.Init(); InitAis(); InterpolateUtils.preview = previewPicturebox; diff --git a/Code/OS/NvApi.cs b/Code/OS/NvApi.cs index c1f1fdc..2425d1a 100644 --- a/Code/OS/NvApi.cs +++ b/Code/OS/NvApi.cs @@ -2,53 +2,60 @@ using NvAPIWrapper.GPU; using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace Flowframes.OS { class NvApi { - static PhysicalGPU gpu; + static List gpuList = new List(); - public static async void Init() + public static void Init() { try { NVIDIA.Initialize(); PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs(); + if (gpus.Length == 0) return; - gpu = gpus[0]; - Logger.Log($"Initialized NvApi. GPU: {gpu.FullName} - Tensor Cores: {HasTensorCores()}"); + gpuList = gpus.ToList(); + + List gpuNames = new List(); + + foreach (PhysicalGPU gpu in gpus) + gpuNames.Add(gpu.FullName); + + string gpuNamesList = string.Join(", ", gpuNames); + + Logger.Log($"Initialized Nvidia API. GPU{(gpus.Length > 1 ? "s" : "")}: {gpuNamesList}"); } catch (Exception e) { - Logger.Log($"Failed to initialize NvApi: {e.Message}\nIgnore this if you don't have an Nvidia GPU."); + Logger.Log("No Nvidia GPU(s) detected. You will not be able to use CUDA implementations."); + Logger.Log($"Failed to initialize NvApi: {e.Message}\nIgnore this if you don't have an Nvidia GPU.", true); } } - public static float GetVramGb () + public static float GetVramGb (int gpu = 0) { try { - return (gpu.MemoryInformation.AvailableDedicatedVideoMemoryInkB / 1000f / 1024f); + return (gpuList[gpu].MemoryInformation.AvailableDedicatedVideoMemoryInkB / 1000f / 1024f); } - catch (Exception e) + catch { return 0f; } } - public static float GetFreeVramGb() + public static float GetFreeVramGb(int gpu = 0) { try { - return (gpu.MemoryInformation.CurrentAvailableDedicatedVideoMemoryInkB / 1000f / 1024f); + return (gpuList[gpu].MemoryInformation.CurrentAvailableDedicatedVideoMemoryInkB / 1000f / 1024f); } catch { @@ -73,15 +80,15 @@ namespace Flowframes.OS } } - public static bool HasTensorCores () + public static bool HasTensorCores (int gpu = 0) { - if (gpu == null) + if (gpuList == null) Init(); - if (gpu == null) + if (gpuList == null) return false; - string gpuName = gpu.FullName; + string gpuName = gpuList[gpu].FullName; return (gpuName.Contains("RTX ") || gpuName.Contains("Tesla V") || gpuName.Contains("Tesla T")); } diff --git a/Code/OS/Updater.cs b/Code/OS/Updater.cs index 40d42a0..12d56d9 100644 --- a/Code/OS/Updater.cs +++ b/Code/OS/Updater.cs @@ -26,7 +26,8 @@ namespace Flowframes.OS } catch (Exception e) { - Logger.Log("Error getting installed version: " + e.Message); + Logger.Log("Error getting installed version!"); + Logger.Log(e.Message, true); return new Version(0, 0, 0); } } diff --git a/Code/Program.cs b/Code/Program.cs index 04cae6e..e847619 100644 --- a/Code/Program.cs +++ b/Code/Program.cs @@ -30,7 +30,6 @@ namespace Flowframes IOUtils.DeleteContentsOfDir(Paths.GetLogPath()); // Clear out older logs from previous session Networks.Init(); - NvApi.Init(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);