diff --git a/.gitignore b/.gitignore index 8dd4607..8a30d25 100644 --- a/.gitignore +++ b/.gitignore @@ -395,4 +395,4 @@ FodyWeavers.xsd *.msp # JetBrains Rider -*.sln.iml \ No newline at end of file +*.sln.iml diff --git a/FastGPU-P/Form1.Designer.cs b/FastGPU-P/Form1.Designer.cs index 5275304..eebf6d1 100644 --- a/FastGPU-P/Form1.Designer.cs +++ b/FastGPU-P/Form1.Designer.cs @@ -28,164 +28,148 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.gpuBox = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.vmBox = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); - this.addButton = new System.Windows.Forms.Button(); - this.AllocationLabel = new System.Windows.Forms.Label(); - this.allocationBar = new MetroFramework.Controls.MetroTrackBar(); - this.allocLabel = new System.Windows.Forms.Label(); - this.installDriver = new System.Windows.Forms.Button(); - this.RemoveButton = new System.Windows.Forms.Button(); - this.mountVHD = new System.Windows.Forms.Button(); - this.vhdBox = new System.Windows.Forms.ComboBox(); - this.label3 = new System.Windows.Forms.Label(); - this.SuspendLayout(); + gpuBox = new ComboBox(); + label1 = new Label(); + vmBox = new ComboBox(); + label2 = new Label(); + addButton = new Button(); + AllocationLabel = new Label(); + allocationBar = new MetroFramework.Controls.MetroTrackBar(); + allocLabel = new Label(); + installDriverBtn = new Button(); + RemoveButton = new Button(); + label3 = new Label(); + SuspendLayout(); // // gpuBox // - this.gpuBox.FormattingEnabled = true; - this.gpuBox.Location = new System.Drawing.Point(25, 174); - this.gpuBox.Name = "gpuBox"; - this.gpuBox.Size = new System.Drawing.Size(315, 28); - this.gpuBox.TabIndex = 0; + gpuBox.FormattingEnabled = true; + gpuBox.Location = new Point(22, 130); + gpuBox.Margin = new Padding(3, 2, 3, 2); + gpuBox.Name = "gpuBox"; + gpuBox.Size = new Size(276, 23); + gpuBox.TabIndex = 0; // // label1 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(25, 151); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(37, 20); - this.label1.TabIndex = 1; - this.label1.Text = "GPU"; + label1.AutoSize = true; + label1.Location = new Point(22, 113); + label1.Name = "label1"; + label1.Size = new Size(30, 15); + label1.TabIndex = 1; + label1.Text = "GPU"; // // vmBox // - this.vmBox.FormattingEnabled = true; - this.vmBox.Location = new System.Drawing.Point(23, 107); - this.vmBox.Name = "vmBox"; - this.vmBox.Size = new System.Drawing.Size(317, 28); - this.vmBox.TabIndex = 2; + vmBox.FormattingEnabled = true; + vmBox.Location = new Point(20, 80); + vmBox.Margin = new Padding(3, 2, 3, 2); + vmBox.Name = "vmBox"; + vmBox.Size = new Size(278, 23); + vmBox.TabIndex = 2; // // label2 // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(25, 81); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(31, 20); - this.label2.TabIndex = 3; - this.label2.Text = "VM"; + label2.AutoSize = true; + label2.Location = new Point(22, 61); + label2.Name = "label2"; + label2.Size = new Size(25, 15); + label2.TabIndex = 3; + label2.Text = "VM"; // // addButton // - this.addButton.Location = new System.Drawing.Point(25, 301); - this.addButton.Name = "addButton"; - this.addButton.Size = new System.Drawing.Size(144, 29); - this.addButton.TabIndex = 4; - this.addButton.Text = "Add"; - this.addButton.UseVisualStyleBackColor = true; - this.addButton.Click += new System.EventHandler(this.addButton_Click); + addButton.Location = new Point(22, 226); + addButton.Margin = new Padding(3, 2, 3, 2); + addButton.Name = "addButton"; + addButton.Size = new Size(126, 22); + addButton.TabIndex = 4; + addButton.Text = "Add"; + addButton.UseVisualStyleBackColor = true; + addButton.Click += addButton_Click; // // AllocationLabel // - this.AllocationLabel.AutoSize = true; - this.AllocationLabel.Location = new System.Drawing.Point(27, 214); - this.AllocationLabel.Name = "AllocationLabel"; - this.AllocationLabel.Size = new System.Drawing.Size(156, 20); - this.AllocationLabel.TabIndex = 6; - this.AllocationLabel.Text = "Allocation percentage"; + AllocationLabel.AutoSize = true; + AllocationLabel.Location = new Point(24, 160); + AllocationLabel.Name = "AllocationLabel"; + AllocationLabel.Size = new Size(123, 15); + AllocationLabel.TabIndex = 6; + AllocationLabel.Text = "Allocation percentage"; // // allocationBar // - this.allocationBar.BackColor = System.Drawing.Color.Transparent; - this.allocationBar.Location = new System.Drawing.Point(27, 246); - this.allocationBar.Name = "allocationBar"; - this.allocationBar.Size = new System.Drawing.Size(255, 29); - this.allocationBar.TabIndex = 7; - this.allocationBar.Text = "null"; - this.allocationBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.allocationBar_Scroll); + 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.TabIndex = 7; + allocationBar.Text = "null"; + allocationBar.Scroll += allocationBar_Scroll; // // allocLabel // - this.allocLabel.AutoSize = true; - this.allocLabel.Location = new System.Drawing.Point(297, 247); - this.allocLabel.Name = "allocLabel"; - this.allocLabel.Size = new System.Drawing.Size(37, 20); - this.allocLabel.TabIndex = 8; - this.allocLabel.Text = "50%"; + allocLabel.AutoSize = true; + allocLabel.Location = new Point(260, 185); + allocLabel.Name = "allocLabel"; + allocLabel.Size = new Size(29, 15); + allocLabel.TabIndex = 8; + allocLabel.Text = "50%"; // - // installDriver + // installDriverBtn // - this.installDriver.Location = new System.Drawing.Point(91, 372); - this.installDriver.Name = "installDriver"; - this.installDriver.Size = new System.Drawing.Size(243, 29); - this.installDriver.TabIndex = 9; - this.installDriver.Text = "install/update driver"; - this.installDriver.UseVisualStyleBackColor = true; - this.installDriver.Click += new System.EventHandler(this.installDriver_Click); + installDriverBtn.Location = new Point(24, 252); + installDriverBtn.Margin = new Padding(3, 2, 3, 2); + installDriverBtn.Name = "installDriverBtn"; + installDriverBtn.Size = new Size(268, 22); + installDriverBtn.TabIndex = 9; + installDriverBtn.Text = "install/update driver"; + installDriverBtn.UseVisualStyleBackColor = true; + installDriverBtn.Click += installDriverBtn_Click; // // RemoveButton // - this.RemoveButton.Location = new System.Drawing.Point(175, 301); - this.RemoveButton.Name = "RemoveButton"; - this.RemoveButton.Size = new System.Drawing.Size(159, 29); - this.RemoveButton.TabIndex = 10; - this.RemoveButton.Text = "Remove"; - this.RemoveButton.UseVisualStyleBackColor = true; - this.RemoveButton.Click += new System.EventHandler(this.RemoveButton_Click); - // - // mountVHD - // - this.mountVHD.Location = new System.Drawing.Point(27, 338); - this.mountVHD.Name = "mountVHD"; - this.mountVHD.Size = new System.Drawing.Size(307, 29); - this.mountVHD.TabIndex = 11; - this.mountVHD.Text = "Mount VHD"; - this.mountVHD.UseVisualStyleBackColor = true; - this.mountVHD.Click += new System.EventHandler(this.mountVHD_Click); - // - // vhdBox - // - this.vhdBox.FormattingEnabled = true; - this.vhdBox.Location = new System.Drawing.Point(27, 373); - this.vhdBox.Name = "vhdBox"; - this.vhdBox.Size = new System.Drawing.Size(58, 28); - this.vhdBox.TabIndex = 12; - this.vhdBox.Click += new System.EventHandler(this.vhdBox_Click); + RemoveButton.Location = new Point(153, 226); + RemoveButton.Margin = new Padding(3, 2, 3, 2); + RemoveButton.Name = "RemoveButton"; + RemoveButton.Size = new Size(139, 22); + RemoveButton.TabIndex = 10; + RemoveButton.Text = "Remove"; + RemoveButton.UseVisualStyleBackColor = true; + RemoveButton.Click += RemoveButton_Click; // // label3 // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(91, 429); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(176, 20); - this.label3.TabIndex = 13; - this.label3.Text = "with ❤ by @b1on1cdog"; + label3.AutoSize = true; + label3.Location = new Point(80, 276); + label3.Name = "label3"; + label3.Size = new Size(135, 15); + label3.TabIndex = 13; + label3.Text = "with ❤ by @b1on1cdog"; // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(360, 465); - this.Controls.Add(this.label3); - this.Controls.Add(this.vhdBox); - this.Controls.Add(this.mountVHD); - this.Controls.Add(this.RemoveButton); - this.Controls.Add(this.installDriver); - this.Controls.Add(this.allocLabel); - this.Controls.Add(this.allocationBar); - this.Controls.Add(this.AllocationLabel); - this.Controls.Add(this.addButton); - this.Controls.Add(this.label2); - this.Controls.Add(this.vmBox); - this.Controls.Add(this.label1); - this.Controls.Add(this.gpuBox); - this.Name = "Form1"; - this.Text = "Fast GPU-P"; - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(315, 303); + Controls.Add(label3); + Controls.Add(RemoveButton); + Controls.Add(installDriverBtn); + Controls.Add(allocLabel); + Controls.Add(allocationBar); + Controls.Add(AllocationLabel); + Controls.Add(addButton); + Controls.Add(label2); + Controls.Add(vmBox); + Controls.Add(label1); + Controls.Add(gpuBox); + Margin = new Padding(3, 2, 3, 2); + Name = "Form1"; + Padding = new Padding(18, 60, 18, 15); + Text = "Fast GPU-P"; + ResumeLayout(false); + PerformLayout(); } #endregion @@ -198,10 +182,8 @@ private void InitializeComponent() private Label AllocationLabel; private MetroFramework.Controls.MetroTrackBar allocationBar; private Label allocLabel; - private Button installDriver; + private Button installDriverBtn; private Button RemoveButton; - private Button mountVHD; - private ComboBox vhdBox; private Label label3; } } \ No newline at end of file diff --git a/FastGPU-P/Form1.cs b/FastGPU-P/Form1.cs index c0be05e..c4e777b 100644 --- a/FastGPU-P/Form1.cs +++ b/FastGPU-P/Form1.cs @@ -24,7 +24,7 @@ private void Form1_Shown(Object sender, EventArgs e) { gpuBox.Items.Add(obj["Name"]); Console.WriteLine(); - i++; + i++; } } @@ -47,13 +47,13 @@ private void Form1_Shown(Object sender, EventArgs e) private void allocationBar_Scroll(object sender, ScrollEventArgs e) { - this.allocLabel.Text = allocationBar.Value.ToString()+"%"; + this.allocLabel.Text = allocationBar.Value.ToString() + "%"; } private string getGPUInstance(string name) { string _scr = (@" $PartitionableGPUList = Get-CimInstance -Class Msvm_PartitionableGpu -Namespace root\virtualization\v2 - $DeviceID = ((Get-CimInstance -ClassName Win32_PNPSignedDriver | where {($_.Devicename -eq " + "\""+name+"\""+ @")}).hardwareid).split('\')[1] + $DeviceID = ((Get-CimInstance -ClassName Win32_PNPSignedDriver | where {($_.Devicename -eq " + "\"" + name + "\"" + @")}).hardwareid).split('\')[1] $DevicePathName = ($PartitionableGPUList | Where-Object name -like *$DeviceID*).Name $DevicePathName | Select "); @@ -78,7 +78,7 @@ private void addButton_Click(object sender, EventArgs e) var isWin10 = (os.Version.Major == 10 && os.Version.Build < 22000); //Instance path only applied if system has more than one GPU or windows 11. - var _instacePath = @"-InstancePath $instance"; + var _instacePath = @"-InstancePath $instance"; if (gpuBox.Items.Count == 1 || isWin10) { _instacePath = string.Empty; @@ -86,10 +86,10 @@ private void addButton_Click(object sender, EventArgs e) string _scr = (@" Set-ExecutionPolicy -ExecutionPolicy Unrestricted - $VMName = " + "\""+ vmBox.GetItemText(vmBox.Text) + "\"" +@" - $instance = "+ "\""+ getGPUInstance(gpuBox.Text) + "\""+ @" + $VMName = " + "\"" + vmBox.GetItemText(vmBox.Text) + "\"" + @" + $instance = " + "\"" + getGPUInstance(gpuBox.Text) + "\"" + @" [decimal]$GPUResourceAllocationPercentage = " + allocationBar.Value.ToString() + @" - Add-VMGpuPartitionAdapter -VMName $VMName "+ _instacePath + @" + Add-VMGpuPartitionAdapter -VMName $VMName " + _instacePath + @" [float]$devider = [math]::round($(100 / $GPUResourceAllocationPercentage),2) Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionVRAM ([math]::round($(1000000000 / $devider))) -MaxPartitionVRAM ([math]::round($(1000000000 / $devider))) -OptimalPartitionVRAM ([math]::round($(1000000000 / $devider))) Set-VMGPUPartitionAdapter -VMName $VMName -MinPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -MaxPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -OptimalPartitionEncode ([math]::round($(18446744073709551615 / $devider))) @@ -112,62 +112,62 @@ private void addButton_Click(object sender, EventArgs e) } } - private void installDriver_Click(object sender, EventArgs e) + private void installDriver() { // string _scr = @" Set-ExecutionPolicy -ExecutionPolicy Unrestricted Import-Module Storage Function Add-VMGpuPartitionAdapterFiles { -param( -[string]$hostname = $ENV:COMPUTERNAME, -[string]$DriveLetter, -[string]$GPUName -) - -If (!($DriveLetter -like ""*:*"")) { - $DriveLetter = $Driveletter + "":"" + param( + [string]$hostname = $ENV:COMPUTERNAME, + [string]$DriveLetter, + [string]$GPUName + ) + + If (!($DriveLetter -like ""*:*"")) { + $DriveLetter = $Driveletter + "":"" } -If ($GPUName -eq ""AUTO"") { - $PartitionableGPUList = Get-CimInstance -Class Msvm_PartitionableGpu -Namespace root\virtualization\v2 - $DevicePathName = $PartitionableGPUList.Name | Select-Object -First 1 - $GPU = Get-PnpDevice | Where-Object {($_.DeviceID -like ""*$($DevicePathName.Substring(8,16))*"") -and ($_.Status -eq ""OK"")} | Select-Object -First 1 - $GPUName = $GPU.Friendlyname - $GPUServiceName = $GPU.Service - } -Else { - $GPU = Get-PnpDevice | Where-Object {($_.Name -eq ""$GPUName"") -and ($_.Status -eq ""OK"")} | Select-Object -First 1 - $GPUServiceName = $GPU.Service + If ($GPUName -eq ""AUTO"") { + $PartitionableGPUList = Get-CimInstance -Class Msvm_PartitionableGpu -Namespace root\virtualization\v2 + $DevicePathName = $PartitionableGPUList.Name | Select-Object -First 1 + $GPU = Get-PnpDevice | Where-Object {($_.DeviceID -like ""*$($DevicePathName.Substring(8,16))*"") -and ($_.Status -eq ""OK"")} | Select-Object -First 1 + $GPUName = $GPU.Friendlyname + $GPUServiceName = $GPU.Service + } + Else { + $GPU = Get-PnpDevice | Where-Object {($_.Name -eq ""$GPUName"") -and ($_.Status -eq ""OK"")} | Select-Object -First 1 + $GPUServiceName = $GPU.Service } -# Get Third Party drivers used, that are not provided by Microsoft and presumably included in the OS + # Get Third Party drivers used, that are not provided by Microsoft and presumably included in the OS -Write-Host ""INFO : Finding and copying driver files for $GPUName to VM. This could take a while..."" + Write-Host ""INFO : Finding and copying driver files for $GPUName to VM. This could take a while..."" -$Drivers = Get-CimInstance -ClassName Win32_PNPSignedDriver | where {$_.DeviceName -eq ""$GPUName""} + $Drivers = Get-CimInstance -ClassName Win32_PNPSignedDriver | where {$_.DeviceName -eq ""$GPUName""} -New-Item -ItemType Directory -Path ""$DriveLetter\windows\system32\HostDriverStore"" -Force | Out-Null -#copy directory associated with sys file -$servicePath = (Get-CimInstance -ClassName Win32_SystemDriver | Where-Object {$_.Name -eq ""$GPUServiceName""}).Pathname - $ServiceDriverDir = $servicepath.split('\')[0..5] -join('\') - $ServicedriverDest = (""$driveletter"" + ""\"" + $($servicepath.split('\')[1..5] -join('\'))).Replace(""DriverStore"",""HostDriverStore"") - if (!(Test-Path $ServicedriverDest)) { - Copy-item -path ""$ServiceDriverDir"" -Destination ""$ServicedriverDest"" -Recurse - } + New-Item -ItemType Directory -Path ""$DriveLetter\windows\system32\HostDriverStore"" -Force | Out-Null + #copy directory associated with sys file + $servicePath = (Get-CimInstance -ClassName Win32_SystemDriver | Where-Object {$_.Name -eq ""$GPUServiceName""}).Pathname + $ServiceDriverDir = $servicepath.split('\')[0..5] -join('\') + $ServicedriverDest = (""$driveletter"" + ""\"" + $($servicepath.split('\')[1..5] -join('\'))).Replace(""DriverStore"",""HostDriverStore"") + if (!(Test-Path $ServicedriverDest)) { + Copy-item -path ""$ServiceDriverDir"" -Destination ""$ServicedriverDest"" -Recurse + } -# Initialize the list of detected driver packages as an array -$DriverFolders = @() -foreach ($d in $drivers) { - $DriverFiles = @() - $ModifiedDeviceID = $d.DeviceID -replace ""\\"", ""\\"" - $Antecedent = ""\\"" + $hostname + ""\ROOT\cimv2:Win32_PNPSignedDriver.DeviceID=""""$ModifiedDeviceID"""""" - $DriverFiles += Get-CimInstance -ClassName Win32_PNPSignedDriverCIMDataFile | where {$_.Antecedent -eq $Antecedent} - $DriverName = $d.DeviceName - $DriverID = $d.DeviceID - if ($DriverName -like ""NVIDIA*"") { - New-Item -ItemType Directory -Path ""$driveletter\Windows\System32\drivers\Nvidia Corporation\"" -Force | Out-Null + # Initialize the list of detected driver packages as an array + $DriverFolders = @() + foreach ($d in $drivers) { + $DriverFiles = @() + $ModifiedDeviceID = $d.DeviceID -replace ""\\"", ""\\"" + $Antecedent = ""\\"" + $hostname + ""\ROOT\cimv2:Win32_PNPSignedDriver.DeviceID=""""$ModifiedDeviceID"""""" + $DriverFiles += Get-CimInstance -ClassName Win32_PNPSignedDriverCIMDataFile | where {$_.Antecedent -eq $Antecedent} + $DriverName = $d.DeviceName + $DriverID = $d.DeviceID + if ($DriverName -like ""NVIDIA*"") { + New-Item -ItemType Directory -Path ""$driveletter\Windows\System32\drivers\Nvidia Corporation\"" -Force | Out-Null } - foreach ($i in $DriverFiles) { + foreach ($i in $DriverFiles) { $path = $i.Dependent.Split(""="")[1] -replace '\\\\', '\' $path2 = $path.Substring(1,$path.Length-2) $InfItem = Get-Item -Path $path2 @@ -176,7 +176,7 @@ Function Add-VMGpuPartitionAdapterFiles { $DriverDir = $path2.split('\')[0..5] -join('\') $driverDest = (""$driveletter"" + ""\"" + $($path2.split('\')[1..5] -join('\'))).Replace(""driverstore"",""HostDriverStore"") if (!(Test-Path $driverDest)) { - Copy-item -path ""$DriverDir"" -Destination ""$driverDest"" -Recurse + Copy-item -path ""$DriverDir"" -Destination ""$driverDest"" -Recurse } } Else { @@ -189,9 +189,8 @@ Function Add-VMGpuPartitionAdapterFiles { } + } } - } - } [string]$VMName = " + "\"" + vmBox.Text + "\"" + @" [string]$GPUName = " + "\"" + gpuBox.Text + "\"" + @" @@ -201,20 +200,24 @@ Function Add-VMGpuPartitionAdapterFiles { If ($VM.state -eq ""Running"") { [bool]$state_was_running = $true - } +} if ($VM.state -ne ""Off""){ ""Attemping to shutdown VM..."" Stop-VM -Name $VMName -Force - } +} While ($VM.State -ne ""Off"") { Start-Sleep -s 3 ""Waiting for VM to shutdown - make sure there are no unsaved documents..."" - } +} ""Mounting Drive..."" -$DriveLetter = " + "\"" + vhdBox.Text+"\""+@" +$DiskNumber = (Mount-VHD -NoDriveLetter -Path $VHD.Path -PassThru | Get-Disk).Number +$PartitionNumber = (Get-Partition -DiskNumber $DiskNumber | Where-Object {$_.Type -eq ""Basic""}).PartitionNumber +$UsedLetters = Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object -ExpandProperty DeviceID | ForEach-Object { $_.ToString()[0] } +$DriveLetter = [char[]](67..90) | Where-Object { $_ -notin $UsedLetters } | Select-Object -First 1 +Set-Partition -DiskNumber $DiskNumber -PartitionNumber $PartitionNumber -NewDriveLetter $DriveLetter ""Copying GPU Files - this could take a while..."" Add-VMGPUPartitionAdapterFiles -hostname $Hostname -DriveLetter $DriveLetter -GPUName $GPUName @@ -225,8 +228,7 @@ Function Add-VMGpuPartitionAdapterFiles { If ($state_was_running){ ""Previous State was running so starting VM..."" Start-VM $VMName - } - +} "; var _ps = PowerShell.Create(); _ps.AddScript(_scr); @@ -241,78 +243,26 @@ Function Add-VMGpuPartitionAdapterFiles { } // } - private void LoadDrives() - { - vhdBox.Items.Clear(); - string _sdr = (@"(Get-PSDrive -PSProvider FileSystem).Root"); - var _pz = PowerShell.Create(); - _pz.AddScript(_sdr); - Collection _zObj = _pz.Invoke(); - if (_pz.HadErrors) - { - MessageBox.Show(_pz.Streams.Error[0].ToString()); - } - else - { - foreach (PSObject _driveletter in _zObj) - { - string letter = _driveletter.ToString(); - letter = letter.Replace(":\\", ""); - if (letter != "C" && letter.Length < 3) - { - vhdBox.Items.Add(letter); - } - - } - } - } - private void mountVHD_Click(object sender, EventArgs e) + private void RemoveButton_Click(object sender, EventArgs e) { - string _scr = (@" -Import-Module Storage -Set-ExecutionPolicy -ExecutionPolicy Unrestricted -[string]$VMName = " + "\"" + vmBox.Text + "\"" + @" -$VM = Get-VM -VMName $VMName -$VHD = Get-VHD -VMId $VM.VMId -Mount-VHD -Path $VHD.Path -PassThru -"); + string _scr = ("Remove-VMGpuPartitionAdapter -VMName " + "\"" + vmBox.Text + "\""); var _ps = PowerShell.Create(); _ps.AddScript(_scr); - Collection _cObj = _ps.Invoke(); + _ps.Invoke(); if (_ps.HadErrors) { - MessageBox.Show(_ps.Streams.Error[0].ToString()); + Console.WriteLine(_ps.Streams.Error[0].ToString()); } else { - Process procDM = new Process(); - procDM.StartInfo.FileName = "C:\\Windows\\System32\\mmc.exe"; - procDM.StartInfo.Arguments = "C:\\Windows\\System32\\diskmgmt.msc"; - procDM.Start(); - MessageBox.Show("VHD Mounted Successfully!"); - LoadDrives(); + MessageBox.Show("successfully removed all GPU Partitions from VM"); } } - private void vhdBox_Click(object sender, EventArgs e) + private void installDriverBtn_Click(object sender, EventArgs e) { - LoadDrives(); - } - - private void RemoveButton_Click(object sender, EventArgs e) - { - string _scr = ("Remove-VMGpuPartitionAdapter -VMName " +"\"" + vmBox.Text + "\""); - var _ps = PowerShell.Create(); - _ps.AddScript(_scr); - _ps.Invoke(); - if (_ps.HadErrors) - { - Console.WriteLine(_ps.Streams.Error[0].ToString()); - } - else { - MessageBox.Show("successfully removed all GPU Partitions from VM"); - } + installDriver(); } } } diff --git a/FastGPU-P/obj/Debug/net6.0-windows/FastGPU-P.assets.cache b/FastGPU-P/obj/Debug/net6.0-windows/FastGPU-P.assets.cache deleted file mode 100644 index d9f4ffb..0000000 Binary files a/FastGPU-P/obj/Debug/net6.0-windows/FastGPU-P.assets.cache and /dev/null differ diff --git a/FastGPU-P/obj/Debug/net6.0-windows/apphost.exe b/FastGPU-P/obj/Debug/net6.0-windows/apphost.exe deleted file mode 100644 index 96a9bf9..0000000 Binary files a/FastGPU-P/obj/Debug/net6.0-windows/apphost.exe and /dev/null differ diff --git a/README.md b/README.md index 69f92ac..7732d07 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # FastGPUP 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 you press Mount VHD, when done it will open disk management where you'll assign a letter for the mounted drive (if it doesn't already has one) and then you choose that drive letter on the tool and press "install/update driver" button. +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. # Troubleshooting -At the time of this last edit (12:02am GMT-4 16/3/2022) this wasn't tested outside my own PC, if you get an error related to Execution Policy you should execute: +If you get an error related to Execution Policy you should execute: "Set-ExecutionPolicy -ExecutionPolicy Unrestricted" on PowerShell