mayankk2308 / set-egpu Goto Github PK
View Code? Open in Web Editor NEWDisplay-agnostic acceleration of macOS applications using external GPUs.
License: MIT License
Display-agnostic acceleration of macOS applications using external GPUs.
License: MIT License
./set-eGPU.sh: line 164: syntax error near unexpected token `}'
./set-eGPU.sh: line 164: `}'
the latest version from trunk git commit 787427
OSX Mojave
StarCraft II, launched through Battle.net, for example, doesn't seem to be using the eGPU at all, after running the script and "Set eGPU Preference for All Applications".
Macbook Pro 2017 with TouchBar, macOS High Serra 10.13.5, AMD Radeon RX Vega 64
Does it matter if eGPU has a connected display?
Also does it matter which display is set as the main? (I ask because Parallels Desktop prompts me to set the display that is connected to eGPU as the main one.)
Latest release does not work with macOS Big Sur beta. It says "Only macOS 10.13.4 or later compatible."
Bit of an unusual Q / feature request for you - is there any way with this tool or others to emulate an eGPU and actually render on the CPU. I would like to get the XCode simulator to render deterministically on the CPU but that's no longer supported by the XCode simulator team.... This project looks like it could potentially do just that but I don't know how easy it is to create virtual hardware on the Mac....
Becuase I've just sold my eGPU and having some bug that some app still recongise I'm using eGPU, how can I untick use eGPU by default for all my apps? Cheers
There are apps that use additional processes for GPU acceleration (i.e. Microsoft Teams, Slack, Chrome) where this script doesn't really help. It is however pretty easy to fix this, as these processes are usually contained within <something GPU Helper>.app
files, so it's just a matter of selecting these too.
As an example, Google Chrome uses an additional GPU Helper process:
Setting the checkbox Prefer external GPU for just the Google Chrome.app
does not do the trick, because the actual GPU acceleration is ran by the other process. What has worked for me was manually changing that process' checkbox for external GPU preference. Having tested it with other apps, all of these seem to follow the pattern bellow:
Essentially, it's a matter of getting into the application's contents folder and scanning for *.app files.
I would be happy to work on this when I have time, but that might not be for a while. Given how simple this is I would be happy for someone else to take over, should they have the time.
How to set steam's game apps,such as Dota2?
@mayankk2308 If you ever decide to optimize this script, I suggest you take a look at this PLIST file:
~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist has a collection named "LSeGPUIsPreferred".
Opening this collection we see a list of all app bundles.
For each app bundle we have two items. "Item 1" is a number.
Prefer eGPU Selected = 3
Prefer eGPU Not Selected = 2
I think this would be the safest way to modify this via a script and also allow backing up this file if needed.
Example PLIST as XML:
The "data" field is BASE64 encoded.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSeGPUIsPreferred</key>
<dict>
<key>com.apple.BluetoothExplorer</key>
<array>
<data>Ym9vaxADAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAIAAAQAAAADAwAAAAAAIAwAAAABAQAAQXBwbGljYXRpb25zGgAAAAEBAABBZGRpdGlvbmFsIFRvb2xzIGZvciBYY29kZQAACAAAAAEBAABIYXJkd2FyZRYAAAABAQAAQmx1ZXRvb3RoIEV4cGxvcmVyLmFwcAAAEAAAAAEGAAAQAAAAJAAAAEgAAABYAAAACAAAAAQDAAD5FVQLAAAAAAgAAAAEAwAAlxYBBwAAAAAIAAAABAMAAG1IAQcAAAAACAAAAAQDAACDTwEHAAAAABAAAAABBgAAkAAAAKAAAACwAAAAwAAAAAgAAAAABAAAQcIJu3QAAAAYAAAAAQIAAAIAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAgAAAABCQAAZmlsZTovLy8MAAAAAQEAAE1hY2ludG9zaCBIRAgAAAAEAwAAAKAgaHQAAAAIAAAAAAQAAEHBzOSKUFO7JAAAAAEBAAAxNDU0Q0Y1Ny0xQTRGLTQ4QzEtODVEMS0yMjQxNTI0RThFMTEYAAAAAQIAAIEAAAABAAAA7xMAAAEAAAAAAAAAAQAAAAEAAAABAQAALwAAAAAAAAABBQAASAAAAAEBAAAvQXBwbGljYXRpb25zL0FkZGl0aW9uYWwgVG9vbHMgZm9yIFhjb2RlL0hhcmR3YXJlL0JsdWV0b290aCBFeHBsb3Jlci5hcHDMAAAA/v///wEAAAAAAAAAEAAAAAQQA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AAAAESAAABQBAAAAAAAAEiAAAPQAAAAAAAAAEyAAAAQBAAAAAAAAICAAAEABAAAAAAAAMCAAAGwBAAAAAAAAENAAAAQAAAAAAAAAAP8AAHQBAAAAAAAA</data>
<integer>3</integer>
</array>
<key>com.apple.DVDPlayer</key>
<array>
<data>Ym9vaxADAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAIAAAQAAAADAwAAAAAAIAYAAAABAQAAU3lzdGVtAAAHAAAAAQEAAExpYnJhcnkADAAAAAEBAABDb3JlU2VydmljZXMMAAAAAQEAAEFwcGxpY2F0aW9ucw4AAAABAQAARFZEIFBsYXllci5hcHAAABQAAAABBgAAEAAAACAAAAAwAAAARAAAAFgAAAAIAAAABAMAAORYAAD///8PCAAAAAQDAABZWQAA////DwgAAAAEAwAABscAAP///w8IAAAABAMAABd0AQD///8PCAAAAAQDAADFdAEA////DxQAAAABBgAAjAAAAJwAAACsAAAAvAAAAMwAAAAIAAAAAAQAAEHBiGotgAAAGAAAAAECAAACAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAIAAAAAQkAAGZpbGU6Ly8vDAAAAAEBAABNYWNpbnRvc2ggSEQIAAAABAMAAACgIGh0AAAACAAAAAAEAABBwczkilBTuyQAAAABAQAAMTQ1NENGNTctMUE0Ri00OEMxLTg1RDEtMjI0MTUyNEU4RTExGAAAAAECAACBAAAAAQAAAO8TAAABAAAAAAAAAAEAAAABAAAAAQEAAC8AAAAAAAAAAQUAADgAAAABAQAAL1N5c3RlbS9MaWJyYXJ5L0NvcmVTZXJ2aWNlcy9BcHBsaWNhdGlvbnMvRFZEIFBsYXllci5hcHDMAAAA/v///wEAAAAAAAAAEAAAAAQQAABwAAAAAAAAAAUQAADcAAAAAAAAABAQAAAIAQAAAAAAACAQAABYAAAAAAAAADAQAADMAAAAAAAAAEAQAAD4AAAAAAAAAAIgAAC4AQAAAAAAAAUgAAAoAQAAAAAAABAgAAA4AQAAAAAAABEgAABsAQAAAAAAABIgAABMAQAAAAAAABMgAABcAQAAAAAAACAgAACYAQAAAAAAADAgAADEAQAAAAAAABDQAAAEAAAAAAAAAAD/AADMAQAAAAAAAA==</data>
<integer>3</integer>
</array>
<key>com.mowglii.ItsycalApp</key>
<array>
<data>Ym9va3QCAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAEAAAQAAAADAwAAAAAAIAwAAAABAQAAQXBwbGljYXRpb25zCwAAAAEBAABJdHN5Y2FsLmFwcAAIAAAAAQYAABAAAAAkAAAACAAAAAQDAADOCpYEAAAAAAgAAAAEAwAAAYxZBAAAAAAIAAAAAQYAAEgAAABYAAAACAAAAAAEAABBwbICFwAAABgAAAABAgAAAgAAAAAAAAAPAAAAAAAAAAAAAAAAAAAACAAAAAEJAABmaWxlOi8vLwwAAAABAQAATWFjaW50b3NoIEhECAAAAAQDAAAAoCBodAAAAAgAAAAABAAAQcHM5IpQU7skAAAAAQEAADE0NTRDRjU3LTFBNEYtNDhDMS04NUQxLTIyNDE1MjRFOEUxMRgAAAABAgAAgQAAAAEAAADvEwAAAQAAAAAAAAABAAAAAQAAAAEBAAAvAAAAAAAAAAEFAAAZAAAAAQEAAC9BcHBsaWNhdGlvbnMvSXRzeWNhbC5hcHAAAADMAAAA/v///wEAAAAAAAAAEAAAAAQQAAA4AAAAAAAAAAUQAABoAAAAAAAAABAQAACIAAAAAAAAACAQAAAkAAAAAAAAADAQAABYAAAAAAAAAEAQAAB4AAAAAAAAAAIgAAA4AQAAAAAAAAUgAACoAAAAAAAAABAgAAC4AAAAAAAAABEgAADsAAAAAAAAABIgAADMAAAAAAAAABMgAADcAAAAAAAAACAgAAAYAQAAAAAAADAgAABEAQAAAAAAABDQAAAEAAAAAAAAAAD/AABMAQAAAAAAAA==</data>
<integer>3</integer>
</array>
<key>com.apple.Safari</key>
<array>
<data>Ym9va3ACAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbAEAAAQAAAADAwAAAAAAIAwAAAABAQAAQXBwbGljYXRpb25zCgAAAAEBAABTYWZhcmkuYXBwAAAIAAAAAQYAABAAAAAkAAAACAAAAAQDAAAGtykEAAAAAAgAAAAEAwAACbcpBAAAAAAIAAAAAQYAAEgAAABYAAAACAAAAAAEAABBwayxYgAAABgAAAABAgAAAgAAAAAAAAAPAAAAAAAAAAAAAAAAAAAACAAAAAEJAABmaWxlOi8vLwwAAAABAQAATWFjaW50b3NoIEhECAAAAAQDAAAAoCBodAAAAAgAAAAABAAAQcHM5IpQU7skAAAAAQEAADE0NTRDRjU3LTFBNEYtNDhDMS04NUQxLTIyNDE1MjRFOEUxMRgAAAABAgAAgQAAAAEAAADvEwAAAQAAAAAAAAABAAAAAQAAAAEBAAAvAAAAAAAAAAEFAAAYAAAAAQEAAC9BcHBsaWNhdGlvbnMvU2FmYXJpLmFwcMwAAAD+////AQAAAAAAAAAQAAAABBAAADgAAAAAAAAABRAAAGgAAAAAAAAAEBAAAIgAAAAAAAAAIBAAACQAAAAAAAAAMBAAAFgAAAAAAAAAQBAAAHgAAAAAAAAAAiAAADgBAAAAAAAABSAAAKgAAAAAAAAAECAAALgAAAAAAAAAESAAAOwAAAAAAAAAEiAAAMwAAAAAAAAAEyAAANwAAAAAAAAAICAAABgBAAAAAAAAMCAAAEQBAAAAAAAAENAAAAQAAAAAAAAAAP8AAEwBAAAAAAAA</data>
<integer>3</integer>
</array>
</dict>
</dict>
</plist>
Hey there, thanks for making such a useful script. Hopefully Apple makes this easier in a later Mac version.
I noticed that apps like the iOS Simulator are embedded in a directory inside Xcode.app
and aren't picked up by set-eGPU
. I had to enable it manually.
I think by doing a recursive search inside /Applications
you'd be able to detect these.
Is it something you're aware of and would you like me to contribute a PR to fix?
I tried to enable "prefer eGPU" for The Talos Principle, a Steam game, using both the installed shortcut and the script, but this has no effect.
When I browse the game files in Steam with Manage -> Show Local Files, and then open Get Info on the actual game executable, it shows as a "unix application" and has no setting for "prefer eGPU".
Is there any way to enable the eGPU for such executables?
I cannot seem to get this to work with macOS Catalina 10.15 beta (19A501i), it doesn't update any application to be set to "Prefer external graphics card".
I have given the terminal all the permissions needed, but still nothing. The script opens all the different applications "Show info" boxes, but doesn't update the checkbox.
DISCLAIMER: I have not used this software with Mojave
When I set GPU preference for Sid Meier's Civilization.
I got "Could not find bundle ID. No action taken."
-2017 Macbook(with TouchBar)
-OSX(12.13.6)
Details:
Set GPU Preference for Specified Application(s)
Only uppercase input are treated as acronyms (ex. 'FCP').
Partial names return a list of possible applications (ex. 'adobe').
Type 'QUIT' to exit this submenu.
Application Name or Acronym: sid
Searching for possible matches...
Possible Matches:
1 : Sid Meier's Civilization VI
Search complete.
Could not find bundle ID. No action taken.
How do I uninstall if something has gone wrong?
Hi,
Many apps have different sub bundle IDs (Chrome with Chrome Helper, Games Launcher/Client...) and setting GPUSelectionPolicy
to the main one isn't enough.
We have to set GPUSelectionPolicy
for each bundle id to make it work.
I can't find of an easy way to script it (maybe going through all Info.plist
in the app directory and finding the CFBundleIdentifier
for each one).
@mayankk2308 - Have you worked out where macOS is saving the eGPU application preference in Mojave yet?
I would be happy if you could support Homebrew so that we can install set-eGPU via Homebrew.
$ brew install set-egpu
Attempting to run the script as-is fails on 12.3.1, another mac on 11.6.5 (that doesn't have eGPU) also fails to have any output from this command.
Deploying a workaround allows it to function correctly to set / probe the eGPU preferences on the apps.
eweiman@eweiman-mbp-osx ~ % sw_vers
ProductName: macOS
ProductVersion: 12.3.1
BuildVersion: 21E258
This line tries to use ioreg
to determine if the eGPU is connected on Mojave and later.
https://github.com/mayankk2308/set-egpu/blob/master/set-eGPU.sh#L159
# Check eGPU presence for Mojave+
check_egpu_presence() {
(( ${IS_HIGH_SIERRA} == 1 )) && return
EGPU_VENDOR="$(ioreg -n display@0 | grep \"vendor-id\" | cut -d "=" -f2 | sed 's/ <//' | sed 's/>//' | cut -c1-4 | sed -E 's/^(.{2})(.{2}).*$/\2\1/')"
[[ -z "${EGPU_VENDOR}" ]] && echo -e "\nExternal GPU must be plugged in for ${BOLD}set-eGPU${NORMAL} on macOS 10.14+.\n" && exit
}
however this has zero output:
% ioreg -n display@0 | grep \"vendor-id\" | cut -d "=" -f2 | sed 's/ <//' | sed 's/>//' | cut -c1-4 | sed -E 's/^(.{2})(.{2}).*$/\2\1/'|wc -l
0
As a workaround I changed this line to read:
EGPU_VENDOR=AMD
Which then allowed me to run this just fine.
You'd probably be better off using system_profiler
for this kind of check.
Example output (which can be quite verbose with many displays connected):
eweiman@eweiman-mbp-osx ~ % system_profiler SPDisplaysDataType
2022-05-02 11:14:58.005 system_profiler[87107:1263592] Device PreExisted [00000001000006c6] AMD Radeon RX 580
2022-05-02 11:14:58.006 system_profiler[87107:1263592] Device PreExisted [0000000100000622] Intel Iris Pro Graphics
2022-05-02 11:14:58.006 system_profiler[87107:1263592] Synchronize with Metal initialization
2022-05-02 11:15:01.012 system_profiler[87107:1263592] Can't find (Metal) name, location, locationNumber, maxTransferRate
2022-05-02 11:15:01.013 system_profiler[87107:1263592] Synchronize with Metal initialization
2022-05-02 11:15:04.013 system_profiler[87107:1263592] Can't find (Metal) name, location, locationNumber, maxTransferRate
2022-05-02 11:15:04.043 system_profiler[87107:1263592] Synchronize with Metal initialization
2022-05-02 11:15:07.044 system_profiler[87107:1263592] Can't find (Metal) name, location, locationNumber, maxTransferRate
2022-05-02 11:15:07.045 system_profiler[87107:1263592] Synchronize with Metal initialization
2022-05-02 11:15:10.053 system_profiler[87107:1263592] Can't find (Metal) name, location, locationNumber, maxTransferRate
Graphics/Displays:
Intel Iris Pro Graphics 5200:
Chipset Model: Intel Iris Pro Graphics 5200
Type: GPU
Bus: Built-In
VRAM (Dynamic, Max): 1536 MB
Vendor: Intel
Device ID: 0x0d26
Revision ID: 0x0008
Metal Family: Supported, Metal GPUFamily macOS 1
Displays:
Color LCD:
Display Type: Built-In Retina LCD
Resolution: 2880 x 1800 Retina
Framebuffer Depth: 24-Bit Color (ARGB8888)
Mirror: Off
Online: Yes
Automatically Adjust Brightness: Yes
Connection Type: Internal
Radeon RX 580:
Chipset Model: Radeon RX 580
Type: External GPU
Bus: PCIe
PCIe Lane Width: x4
VRAM (Total): 4 GB
Vendor: AMD (0x1002)
Device ID: 0x67df
Revision ID: 0x00e7
Metal Family: Supported, Metal GPUFamily macOS 1
GPU is Removable: Yes
Displays:
DELL P2217H:
Resolution: 1920 x 1080 (1080p FHD - Full High Definition)
UI Looks like: 1920 x 1080 @ 60.00Hz
Framebuffer Depth: 30-Bit Color (ARGB2101010)
Display Serial Number: 4RDG97C71234
Main Display: Yes
Mirror: Off
Online: Yes
Rotation: Supported
You might be able to just grep for "External GPU" in this case, or if you really need the vendor info you could get that as well, however I don't see a reason to get that specific.
eweiman@eweiman-mbp-osx ~ % system_profiler SPDisplaysDataType 2>/dev/null|grep External
Type: External GPU
2016 13 touch bar
gaming box 1060 3g
mojave
Accidentally clicked deny permissions instead of accept #facepalm. Is there a quick fix I missed somewhere? Thanks.
Hi Mayankk, I will try to be brief and specific.
The application is called 'Spark' by 'Iguana 2'. I checked in activity monitor and selected prefer egpu in the info section of the app before trying the script. When I ran the script and checked egpu preferences it confirmed prefer egpu was the setting and still, app refuses to use egpu.
Just tested with the laptop screen flipped closed. The app will use eGPU, so I can force it to use eGPU with the screen closed. After app is running I can then open my laptop screen. It's a fix for now but I don't understand why that changes things. P.s. App always launches in external monitor and external monitor is set as primary monitor
Most if not all apps just give me this error. I've granted all permissions to Terminal from System Preferences and tried running script in sudo manually.
Using macOS 11.1 (20C5061b) on a MacBook Pro 15" Late 2013 w/RX 5700 XT
It would be grat if all my Apps would run on internal Graphics so that all my NVRAM on eGPU is free for CUDA (more specific Tensorflow). From my point of view this is not possible at the moment right ?
When you select apps and it finds multiple you should be able to say all, so for example.
select "adobe" returns 17 results, if I could say "all" in the next prompt it would make pattern matching work better.
that way I can set all my adobe apps to use egpu easily.
Since i installed set-egpu i can't listen to a movie on my macbook while working on my monitor. graphics glitch / freeze a lot. When i unplug my egpu everything go back to normal. How can i uninstall set-egpu the right way ? Thanks in advance.
Will this script works on Catalina 10.15.+
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.