Allow us to choose which GPU to use for Hardware Acceleration

Yorumlar

30 yorum

  • SomeGuy

    I would also like this as an option, I find that when I'm streaming with the iGPU there just isn't enough horsepower to work efficiently, and unless I select my dGPU my resources get hammered pretty bad.

    The solution levvvy post does indeed work, but because of the way that Discord is deployed it's fairly temporary.  The file path changes regularly, and has to be updated or the setting will be lost. For example at the time of this post this is the current path:
    C:\Users\(username)\AppData\Local\Discord\app-1.0.9002\Discord.exe
    ..but on the next update the version label for the folder will change, and the setting will be obsolete. This was easier before when you could right-click and select the GPU to use, and to be honest the change to how apps are run IS a good one, it's just a weird consequence of the way the Discord app is deployed.

    7
  • aTorre98

    I tried the solution @levvvy was suggesting, but still no change for me. In some way, Discord overrides the setting I choose and still uses the dGPU instead of the iGPU.

    3
  • levvvy

    I found a solution to this problem!
    It turned out that windows offers the option to select the GPU for the application!

    In order to force an app to use a discrete GPU instead of the integrated one, or vice versa to provide better system performance or battery life, I suggest you to follow the below steps.

     

        1. Open Settings, and click/tap on the System icon. Click on System.

        2. Click on Display on the left side

        3. Under “Multiple displays,” click the Advanced graphics settings link.

        4. Select the kind of app you want to configured using the drop-down menu:

            Classic app — these are your traditional Win32 desktop programs.

            Universal app — these are those app available through the Microsoft Store.

     

        5. If you select Classic app, you’ll need to click the Browse button to locate the “.exe” file to add the app. Otherwise, if you select the Universal app option, you’ll see a second drop-down menu to select the app.

        6. Select the app you added from the list.

        7. Click the Options button

        8. Set the graphics preference you want to use:

     

            System default — this is always the default setting, and Windows 10 decide which GPU to use automatically.

            Power saving — runs the application on the GPU that uses the least power, which most of the time is your integrated graphics processor.

           High performance — runs the application on the most capable GPU, which is most of the time an external or discrete graphics processor.

     

        9. Click the Save button.

    2
  • niyuuesuto

    Why isn't this possible natively yet on a site used and targeted to people who play games? Bump.

    2
  • Basstard RadOo

    Yes I need it too, and to be kinda honest, Discord is not alone. But this is a must have!

    2
  • Jakob Lund

    Thank you Gerson Aquino for your script. I had trouble running it without errors, so I decided to convert it to a Python script instead.

    For anyone wanting to use it, you can set it up the same way as Gerson described above, if im not mistaken.

    import os
    import winreg

    # Variables
    discord_appdata_dir = os.path.join(os.getenv("LOCALAPPDATA"), "Discord", "Discord.exe")
    discord_registry = r"SOFTWARE\Microsoft\DirectX\UserGpuPreferences"
    power_saving = "GpuPreference=1;"

    # Delete current registry values
    try:
        with winreg.OpenKey(winreg.HKEY_CURRENT_USER, discord_registry, 0, winreg.KEY_ALL_ACCESS) as key:
            winreg.DeleteValue(key, discord_appdata_dir)
    except FileNotFoundError:
        pass  # Key doesn't exist yet

    # Get the correct path of the Discord.exe file in AppData
    path_app = None
    for root, dirs, files in os.walk(os.path.dirname(discord_appdata_dir)):
        if os.path.basename(discord_appdata_dir) in files:
            path_app = os.path.join(root, os.path.basename(discord_appdata_dir))
            break

    # Create updated registry value
    if path_app:
        try:
            key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, discord_registry, 0, winreg.KEY_ALL_ACCESS)
        except FileNotFoundError:
            key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, discord_registry)

        winreg.SetValueEx(key, path_app, 0, winreg.REG_SZ, power_saving)
        winreg.CloseKey(key)

     

    2
  • Splitframe

    Next comment be like:
    Hey I made a discord fork where this is implemented.

    2
  • Chekonjak

    I'm still waiting on this too.

    1
  • BFGManiac

    Bump

    1
  • Jakob Lund

    Sure, Gerson Aquino . I got this error when executing the script:

    Index operation failed; the array index evaluated to null.
    At F:\Scripts\test.ps1:7 char:1
    + Remove-ItemProperty -Path $diretoriaBaseRegisto -Name ($discordBase[$ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
       + FullyQualifiedErrorId : NullArrayIndex

    Index operation failed; the array index evaluated to null.
    At F:\Scripts\test.ps1:10 char:1
    + $pathApp = Get-ChildItem -Path $discordBase[$i][0] -Filter $discordBa ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
       + FullyQualifiedErrorId : NullArrayIndex

    Set-ItemProperty : Cannot bind argument to parameter 'Name' because it is null.
    At F:\Scripts\test.ps1:13 char:52
    + Set-ItemProperty -Path $diretoriaBaseRegisto -Name $pathApp -Value $p ...
    +                                                    ~~~~~~~~
       + CategoryInfo          : InvalidData: (:) [Set-ItemProperty], ParameterBindingValidationException
       + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetItemProp
      ertyCommand

    I have always avoided PowerShell, so I cannot give you anymore than this I'm afraid.

    1
  • The_Lucifer
    #Variables
    $discordBase = @("$env:LOCALAPPDATA\Discord", "Discord.exe")
    $baseRegistryKey = "HKCU:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences";
    $powerSaving = "GpuPreference=1;";
    #Delete current registry values
    Remove-ItemProperty -Path $baseRegistryKey -Name ($discordBase[0] + "\*");
    #Get the correct path of the Discord.exe file in AppData
    $pathApp = Get-ChildItem -Path $discordBase[0] -Filter $discordBase[1] -Recurse -Depth 1 | Select-Object -ExpandProperty FullName;
    #Create updated registry value
    # Set-ItemProperty -Path $baseRegistryKey -Name $pathApp -Value $powerSaving -Type String -Force;
    New-ItemProperty -Path $baseRegistryKey -Name $pathApp -Value $powerSaving -PropertyType String -Force;
    exit;
    

    I've hopefully fixed the script that Gerson Aquino  posted above, works on Win 11 Pro, Powershell. As always, verify before running any code, and I'm not responsible for anything that happens to your computer, as a result of running the above code

    1
  • whoami

    The script and instructions by Gerson Aquino  and The_Lucifer  is useful and works, thanks for sharing! I've run into a couple of issues and wanted to share my experience - I have two GPUs - an AMD 6900XT and Intel Arc A310, my aim is to use the Intel GPU exclusively for media, browser, discord, etc while my main GPU is used exclusively for gaming.

    Firstly, GpuPreference=1 changes the power saving option for the exe - for some reason on my machine both power saving and high performance uses my main GPU. To get around this I manually selected my GPU for the list of devices, and inspected the registry entry and replaced the value in the script. Now the Discord always starts with the correct device, regardless of performance mode of the associated device

    Secondly, Discord auto starts, and therefore auto-updates. The scheduled task usually runs before the update happens, this means that I have to restart discord for this to take affect after an update occurs. I've looked for ways to trigger the task when discord starts, but it doesn't look like Discord posts to Windows Event Logger. As a workaround, I've included a Discord stop-start and adjusted the scheduled task to start after a short delay. This means that after Discord updates and starts up, the registry entry will update and discord will be restarted. 

    It's not perfect, since if discord takes longer than 1 min to update, this will still required a Discord restart. To counter this the scheduled task delay can be increase. This would also be better if it were event driven. I also don't know where to get the adapter and GPU preference ids. I had to update the graphics settings for discord, and select “Specific GPU” and choose the preferred GPU from the list. It might also be intrusive if you jump on Discord immediately after start up, and suddenly get disconnected. 

    # Variables
    $discordPathBase = @("$env:LOCALAPPDATA\Discord", "Discord.exe")
    $baseRegistryKey = "HKCU:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences";
    # Unique ids for GPU can be found in $baseRegistryKey after manually selecting GPU from list in Graphics Settings
    $specificAdapter = "SpecificAdapter=<unique-id-1>;GpuPreference=<unique-id-2>;";
    
    # Delete current registry values
    Remove-ItemProperty -Path $baseRegistryKey -Name ($discordPathBase[0] + "\*");
    
    # Get the correct path of the Discord.exe file in AppData
    $discordPath = Get-ChildItem -Path $discordPathBase[0] -Filter $discordPathBase[1] -Recurse -Depth 1 | Select-Object -ExpandProperty FullName;
    
    # Create updated registry value
    New-ItemProperty -Path $baseRegistryKey -Name $discordPath -Value $specificAdapter -PropertyType String -Force;
    
    # Get the process ID (PID) of Discord
    $discordProcess = Get-Process -Name "Discord" -ErrorAction SilentlyContinue
    
    # If Discord is running, kill the process
    if ($discordProcess -ne $null) {
       Stop-Process -Id $discordProcess.Id -Force
    }
    
    # Wait for a few seconds before relaunching Discord
    Start-Sleep -Seconds 5
    
    # Start Discord without blocking the script's exit
    Start-Process $discordPath -NoNewWindow
    
    exit;
    1
  • EMWIFRO

    bump

    0
  • levvvy

    bump

    0
  • GrandPhydeux

    bump

    0
  • iCookBacon

    Bump, still waiting

    0
  • luckymcbeast

    Bump

    0
  • effleurager

    bump 🚆

    0
  • coldless

    bump

    0
  • Zeith

    bump

    0
  • qa

    bump

    0
  • Splitframe

    Bump.

    0
  • Chekonjak

    How do we know if this has become an internal ticket or not? It has been three years since I found this post and added my vote.

    0
  • Kozelka R

    As a laptop user, it would be nice if I could tell the Discord app to use the iGPU and play games on dGPU.

    I could easily stream with AMD's iGPU while the game renders with dGPU. But it's just sitting there and does nothing.

    0
  • Gerson Aquino

    Ok, so if anyone is still looking for a solution to this, I created a powershell script that should do the trick, at least in Windows 10, haven't tested it in other OS.

    This is the script:

    #Variables
    $discordBase = @("$env:LOCALAPPDATA\Discord", "Discord.exe")
    $diretoriaBaseRegisto = "HKCU:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences";
    $powerSaving = "GpuPreference=1;";
    
    #Delete current registry values
    Remove-ItemProperty -Path $diretoriaBaseRegisto -Name ($discordBase[0] + "\*");
    
    #Get the correct path of the Discord.exe file in AppData
    $pathApp = Get-ChildItem -Path $discordBase[0] -Filter $discordBase[1] -Recurse -Depth 1 | Select-Object -ExpandProperty FullName;
    
    #Create updated registry value
    Set-ItemProperty -Path $diretoriaBaseRegisto -Name $pathApp -Value $powerSaving -Type String -Force;
    
    exit;

     

    This is a simpler version of a script that I created to do the same with a bunch of apps if I want to (if they work like Discord of course).

    But basically, you need to save this in a .ps1 file and set up a task in Task Scheduler to run this after you log in.
    Note that we're messing with registry keys, so you need an Administrator account of course.

    Now some images to ilustrate the instructions:

    1. Create the script file
    1.1 Open the notepad (or any other text editor you like) and copy the script above into it
    1.2 Click “File” → “Save As”, then set “Save as type:” to “All files (*.*)"
    1.3 Change the file extension to “ps1” so that Windows recognizes it as a script instead of a simple text file
    1.4 Save the file in a with a name and location that you'll remember for this tutorial and never delete it, I for example will save the file in C:\Atalhos_Scripts with the name “GPUPreferences.ps1”

    2. Create the task in Task Scheduler
    2.1 Open Windows Search, write “Task Scheduler” and open it

    2.2 On the top left corner right-click “Task Scheduler Library” and “New Folder…”


    2.3 Name the folder whatever you want, I'm using the name “CustomTasks” - here you can write whatever you want really, makes 0 difference
    2.4 Right-click your newly created folder and then “Create Task…”

    2.5 Give the task a name (and optionally a description)
    2.6 Check the “Run with highest privileges” box and change “Configure for:” to “Windows 10” or whatever windows version you're on (even though I do not guarantee these steps are the same for other Windows versions)


    2.7 Select “Triggers” on the top and then click “New…”

    2.8 Now I'm not sure of which trigger works best, so we can create 2, i.e., on the window that opens, you simply change the “Begin the task:” field to “At log on” and click “OK”, then repeat the process but change the field to “At startup” instead.

    Your “Triggers” page should look like this after that.

    Edit: After some testing, the “At log on” trigger is enough, so you can remove the “At startup” if you want, just select it and click the "Delete" button, if not you can let it be, it won't do anything bad, at most it could run the script twice, but it's such a simple script that it runs in less than 1 second on any pc.

     

    2.9 Go to “Actions” and click “New…”

    2.10 In the “Program/script:” field you write “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” (without the quotation marks of course), then in the “Add arguments (optional):” field you're going to write the following:

    -ExecutionPolicy Bypass -WindowStyle hidden -File "C:\Atalhos_Scripts\GPUPreferences.ps1"

    Then click “OK”.

    Note that you must replace what's inside the quotation marks after “-File” by the full path of the script you created, so let's say you saved the script in the folder Garbage that is in disk D and called it bananas.ps1, you'll write -File “D:\Garbage\bananas.ps1”

    You should now have that action in the “Actions” page, like this:

    2.11 Go to “Conditions” and uncheck every box

    2.12 This step is now optional, but I like to go to the “Settings” page and set everything like this, but you can change it as you wish:

     

    That's it, just click “OK” and you should be ready to go.
    The best way to test this is to simply right click the desktop, click “Display Settings”, scroll down to find “Graphics settings” and delete the setting you might have for Discord (if you have it that is)

    Then reboot the pc and check if that setting was added by the script. If it was, then everything is working properly, if it didn't, then you probably did something wrong.
    If discord keeps operating the same way, this will work for any update that they might launch, if not.. well… I guess I'll have to check if I can update the script.

    Note: If discord updates, the changes won't be made untill you force the task to run manually or untill you reboot the pc. To run it manually you have to open the Task Scheduler, open your folder, right-click the task you created and click “Run” then just close and reopen Discord, this should work, if not, just reboot the pc.

    But yeah, that's it, I hope I could help some of you.

    0
  • Gerson Aquino

    It's cool that you made a Python version of the script Jakob Lund, but could you please tell me what kind of errors you got and your Windows version?
    I can try to make some adjustments to avoid such errors if needed but it ran without issues on my machine (Windows 10 Pro, I didn't mentioned it was the Pro version, but it shouldn't make a difference I think), but maybe there are scenarios where it fails, I don't have much experience with PowerShell scripts so that's possible.

    0
  • Gerson Aquino

    The_Lucifer Yeah I actually haven't got a chance to check the script again (or forgot it when I had time), but apparently, I forgot to the remove the “$i” index… the original script has a 2-dimension array and that was in a loop, glad you saw that. It should work with your version, I've updated my post with that correction as well, thanks.

    0
  • DayDay

    This used to be a windows 10 feature but it was removed when 11 came out because they wanted to make it a windows 11 feature, forcing people to upgrade.  

    Go into system > display > graphics and select Discord or whatever app youre trying to do this for.  Select your GPU.   
    Windows 10 will only show your main dedicated GPU and integrated graphics (if you have it) but Windows 11 gives you the option to choose.  I did this for Edge and Discord, restarted both apps and now anytime i stream in discord, watch a stream in discord, or watch any videos on Youtube in Edge, it all uses my Quadro M2000 like I want.  Now I can game on my 4070ti with it not being used for other stuff.  

    This is my task manager when a youtube video is playing in edge and im streaming in discord.  GPU2 is my M2000.  

    0
  • DayDay

    Ive never had to redo the settings that I posted when Discord or Edge updated.  

    0
  • effleurager

    And perform this same rigamarole every time the app is updated, changing the binary location? These are quick fixes, not proper solutions.

    -1

Yorum yazmak için lütfen oturum açın.