diff --git a/FastGPU-P/FastGPU-P.csproj b/FastGPU-P/FastGPU-P.csproj index 1dc6c9f..49b6159 100644 --- a/FastGPU-P/FastGPU-P.csproj +++ b/FastGPU-P/FastGPU-P.csproj @@ -2,7 +2,7 @@ WinExe - net6.0-windows + net10.0-windows FastGPU_P enable true @@ -11,9 +11,9 @@ - - - + + + \ No newline at end of file diff --git a/FastGPU-P/Form1.Designer.cs b/FastGPU-P/Form1.Designer.cs index eebf6d1..1a57894 100644 --- a/FastGPU-P/Form1.Designer.cs +++ b/FastGPU-P/Form1.Designer.cs @@ -34,7 +34,10 @@ private void InitializeComponent() label2 = new Label(); addButton = new Button(); AllocationLabel = new Label(); - allocationBar = new MetroFramework.Controls.MetroTrackBar(); + allocationBar = new TrackBar(); + allocationBar.Minimum = 0; + allocationBar.Maximum = 100; + allocationBar.Value = 50; allocLabel = new Label(); installDriverBtn = new Button(); RemoveButton = new Button(); @@ -99,13 +102,11 @@ private void InitializeComponent() // // allocationBar // - allocationBar.BackColor = Color.Transparent; allocationBar.Location = new Point(24, 184); allocationBar.Margin = new Padding(3, 2, 3, 2); allocationBar.Name = "allocationBar"; - allocationBar.Size = new Size(223, 22); + allocationBar.Size = new Size(223, 45); allocationBar.TabIndex = 7; - allocationBar.Text = "null"; allocationBar.Scroll += allocationBar_Scroll; // // allocLabel @@ -180,7 +181,7 @@ private void InitializeComponent() private Label label2; private Button addButton; private Label AllocationLabel; - private MetroFramework.Controls.MetroTrackBar allocationBar; + private TrackBar allocationBar; private Label allocLabel; private Button installDriverBtn; private Button RemoveButton; diff --git a/FastGPU-P/Form1.cs b/FastGPU-P/Form1.cs index c4e777b..53c6fe5 100644 --- a/FastGPU-P/Form1.cs +++ b/FastGPU-P/Form1.cs @@ -1,4 +1,5 @@ -using MetroFramework.Forms; +using MaterialSkin.Controls; +using MaterialSkin; using System.Management.Automation; using System.Diagnostics; using System.Collections.ObjectModel; @@ -6,15 +7,24 @@ namespace FastGPU_P { - public partial class Form1 : MetroForm + public partial class Form1 : MaterialForm { public Form1() { InitializeComponent(); + // MaterialSkin manager setup + var materialSkinManager = MaterialSkinManager.Instance; + materialSkinManager.AddFormToManage(this); + materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; + materialSkinManager.ColorScheme = new ColorScheme( + Primary.Blue600, Primary.Blue700, + Primary.Blue200, Accent.LightBlue200, + TextShade.WHITE + ); Shown += Form1_Shown; } - private void Form1_Shown(Object sender, EventArgs e) + private void Form1_Shown(object? sender, EventArgs e) { int i = 0; @@ -45,7 +55,7 @@ private void Form1_Shown(Object sender, EventArgs e) } - private void allocationBar_Scroll(object sender, ScrollEventArgs e) + private void allocationBar_Scroll(object sender, EventArgs e) { this.allocLabel.Text = allocationBar.Value.ToString() + "%"; } @@ -85,7 +95,8 @@ private void addButton_Click(object sender, EventArgs e) } string _scr = (@" - Set-ExecutionPolicy -ExecutionPolicy Unrestricted + $oldPolicy = Get-ExecutionPolicy + Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process $VMName = " + "\"" + vmBox.GetItemText(vmBox.Text) + "\"" + @" $instance = " + "\"" + getGPUInstance(gpuBox.Text) + "\"" + @" [decimal]$GPUResourceAllocationPercentage = " + allocationBar.Value.ToString() + @" @@ -98,6 +109,7 @@ private void addButton_Click(object sender, EventArgs e) Set-VM -GuestControlledCacheTypes $true -VMName $VMName Set-VM -LowMemoryMappedIoSpace 1Gb -VMName $VMName Set-VM -HighMemoryMappedIoSpace 32GB -VMName $VMName + Set-ExecutionPolicy -ExecutionPolicy $oldPolicy -Scope Process "); var _ps = PowerShell.Create(); _ps.AddScript(_scr); @@ -116,7 +128,8 @@ private void installDriver() { // string _scr = @" -Set-ExecutionPolicy -ExecutionPolicy Unrestricted +$oldPolicy = Get-ExecutionPolicy +Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process Import-Module Storage Function Add-VMGpuPartitionAdapterFiles { param( @@ -229,6 +242,9 @@ Function Add-VMGpuPartitionAdapterFiles { ""Previous State was running so starting VM..."" Start-VM $VMName } +"; + _scr += @" +Set-ExecutionPolicy -ExecutionPolicy $oldPolicy -Scope Process "; var _ps = PowerShell.Create(); _ps.AddScript(_scr); @@ -241,7 +257,6 @@ Function Add-VMGpuPartitionAdapterFiles { { MessageBox.Show("GPU driver updated successfully!"); } - // } private void RemoveButton_Click(object sender, EventArgs e) diff --git a/README.md b/README.md index 7732d07..2f9a5b1 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,28 @@ A WIP GUI app to make GPU-P way easier! Based on : https://github.com/jamesstringerparsec/Easy-GPU-PV ![image](https://github.com/user-attachments/assets/9b732ced-8304-4dc3-afa2-95c409702cfa) # Usage -The usage is simple, choose VM, choose GPU, slide the percentage you want to allocate of it and then press Add. -For drivers, choose VM, and then click install/update driver. It will mount the VM's VHD, copy the driver files, and unmount the VHD. +Requires Visual Studio Code (exe can be provided but dont trust anything from the internet so use the code) + + - Download all files and extract the zip + - Open visual Studio Code as Administrator (right click, run as administrator) + - File -> open folder and open the extracted folder + - Trust the files on the popup (as youve read through the code on github and happy its safe of course) + - Install c# dev kit and .net 10, it should popup when you open the folder asking you to do this + + - In the terminal enter + dotnet build FastGPU-P/FastGPU-P.csproj + and press enter + - In the terminal enter + dotnet run --project FastGPU-P/FastGPU-P.csproj + and press enter + + The GUI will now load + +- Choose VM, +- Choose GPU, +- Slide the percentage you want to allocate of it and then press Add. +- Click install/update driver. It will mount the VM's VHD, copy the driver files, and unmount the VHD. + # Troubleshooting If you get an error related to Execution Policy you should execute: "Set-ExecutionPolicy -ExecutionPolicy Unrestricted" on PowerShell