0xbb / gpu-switch Goto Github PK
View Code? Open in Web Editor NEWgpu-switch is an application that allows to switch between the graphic cards of dual-GPU Macbook Pro models
License: MIT License
gpu-switch is an application that allows to switch between the graphic cards of dual-GPU Macbook Pro models
License: MIT License
FYI your gpu-switch script works as expected on a Macbook Pro 5,1. Should not be surprising given it has the same exact video hardware setup as a Macbook Pro 5,2.
One thing that would be really helpful on your README file is a note on how to figure out which GPU you are currently using.
I found this helpful:
https://unix.stackexchange.com/questions/16407/how-to-check-which-gpu-is-active
So in my case I documented this note for myself:
Find out which GPU you are currently using
glxinfo|egrep "OpenGL vendor|OpenGL renderer"
glxinfo | less # Look for the "Extended renderer info" line.
--
"Device: NVAC" = 9400M (Chipset/onboard GPU)
"Device: NV96" = 9600M GT (Dedicated chip GPU)
Thanks for your script.
Hi,
First of all a big thank you for the effort you put into this. I have a question on whether the tricks needed to get this working on Windows only.
I have a Macbook Pro 11,3 model (mid 2014), but I prefer to work under Windows only (I don't even have OS X or another unix distro installed on my machine). Is it possible to get this to work with just using the first trick in the list (the apple_set_os.efi), or would I also need the last two (patched GRUB and kernel) to get this to work?
If your answer is yes to the question above, can rEFIt be used to place the .efi binary at the correct location on the EFI partition through Windows?
Sorry to post this as an "issue" on your project.
Thanks in advance!
Hi,
I switched to integrated GPU from Windows 10 on my macbook pro 16 intel and when I rebooted I noticed windows will hang at the Windows logo screen while flickering all the time.
Any ideas or any way to revert the changes back on Windows?
Cheers and thanks
MacBook Pro 11.5
OS X 10.12.4
I ran "gpu-switch -i" on my ubuntu partition and ended up with having to reset the nvram on my MacBook, otherwise any OS trying to use the discrete gpu would hang.
I have done it twice... because the first time I was not sure it was the cause. It use to be working before the update to OS X 10.12.4
the script works fine in multi-user mode. but after my os update to high sierra I realized that my macbook again uses the internal gpu, which led again to the well-known permanent reboot scenario and made it impossible for me to enter multi-user mode. How can I make this script working in single-user mode boot status ?? Would be great if someone can help me out of this trap :-)
This is not a real issue but...
First of all thanks for this great job, it looks like it's working smootly on my Mac Book Pro mid 2011.
I have had the know issue with broken AMD Graphic Card, it was substitued then it happened again after a couple years now. I want discrete card to be excluded, I don't need it at all actually! And gpu-switch works smootly.
I also installed the hooks (just changed login option from -a to -i), but having gfxCardStatus enabled seems to overtake gpu-switch and starts back the dynamic switch of cards (which is something I don't want). Am I correct or I am missing something?
Will be enough leaving only login hooks of gpu-switch to achieve that?
As far as I know my situation is this
$ sudo nvram -p | grep gpu
gpu-policy %01
I would use the gpu-switch but the home page says: "WARNING: broken on macOS +10.12.4".
Macbook Pro Early 2011 - Intel HD 3000 and AMD Radeon HD 6750M - Mac OS Sierra 10.12.5
Test: Single-User mode (Command + S) with red background screen and white stripes.
After the reboot, the screen became normal again.
The configuration remains after 3 days with 3 shutdowns.
sudo nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00
. . . . .
There is this procedure that works but some people could not do it through ArchLinux.
FGuarani
https://forums.macrumors.com/threads/force-2011-macbook-pro-8-2-with-failed-amd-gpu-to-always-use-intel-integrated-gpu-efi-variable-fix.2037591/page-5
.
So I decided to search and found that the format "gpu-power-prefs=%01%00%00%00" is not in the correct format.
The correct format is:
sudo nvram GUID:NVRAM_Variable=value
GUID - Standard Apple Macbook Pro Early 2011-> fa4ce28d-b62f-4c99-9cc3-6815686e30f9
NVRAM Variable -> gpu-power-prefs
Value for Integrated gpu - In this case Binary data Hexadecimal (%) -> %01%00%00%00
.
Macbook Pro 2011 (AMD) and Macbook Pro 2014 (Nvidia) have the same GUIDs / UUIDs. I think it's an Apple standard factory.
FA4CE28D-B62F-4C99-9CC3-6815686E30F9:gpu-active
FA4CE28D-B62F-4C99-9CC3-6815686E30F9:gpu-power-prefs
7C436110-AB2A-4BBB-A880-FE41995C9F8:gpu-policy
https://github.com/ah-/gmux-scripts/issues/1#issuecomment-68113930
.
Setting NVRAM Variables from OS X - Wikileaks
Example: DriverOrder
sudo nvram 8BE4DF61-93CA-11D2-AA0D-00E098032B8C:DriverOrder=%00%50
https://wikileaks.org/ciav7p1/cms/page_26968084.html
http://www.insanelymac.com/forum/topic/291655-ozmosis/page-3
I wrote this last summer to avoid doing chainloading shenanigans with GRUB and refind (or using the EFI executable utility). I have a 10,1 (not realizing that, apparently, this hack is only needed on 11,x?).
I figured I'd share it with you guys!
I have a mid-2012 rMBP w/ Intel HD 4000 and a 650M onboard. Has anyone tested on this model? Do you want a guinea pig?
Hello,
Did you know if your solution could work with my version of MBP ? Also did you know if there is a way to use the MBP with bumblebee ? My only way to make X works till now it's with the nvidia nouveau module...
I tried your tool and I get an error:
./gpu-switch: line 44: printf: write error: Invalid argument
So I tried to type it in shell:
printf "\x07\x00\x00\x00\x01\x00\x00\x00" > "/sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9"
and got:
bash: printf: write error: Invalid argument
The efivar exist and the gpu-power-prefs exists too...
Just got the latest code off github and ran the build script.
Freshly booted laptop with gfxCardStatus running in the background.
Running ./gpu-switch -i caused the computer to freeze completely.
Any advice would be helpful.
Model: MacBookPro8,2
OS: macOS Sierra 10.12.4
Happy to share/add further debugging/logging information as needed, to help with fixing this issue.
Hey, thanks for taking the time to work this out!
I'm new to Unix and to Bootcamp. My MBP (Mid 2014) is my first Mac, but like a lot of other new and old users of MBP's, I'm trying to get the switchable graphics working under Bootcamp.
I have successfully gotten Windows 7 (64-bit) installed through Bootcamp, installed rEFInd with apple_set_os.efi in the EFI partition, and can boot into Windows 7 in Safe Mode and see two graphics adapters. And like many others, if I boot into Windows 7 not in Safe Mode, I see the Windows boot logo animate, followed by a black screen and no login jingle.
Using the gpu-switch batch files to solve this issue, though, isn't possible as Windows spits back an error telling me it isn't compatible with 64-bit operating systems. I can't seem to find any compatibility mode to circumvent the issue.
Is that error actually meaningful or is it a sign that the method is simply untested on Windows 7? I don't have a copy of Windows 8 lying around, nor a 32-bit copy of Windows 7 to troubleshoot the problem any further. Please forgive me if the solution is lying right under my nose. I'm so close to getting this working, so please let me know how I can help you in figuring this out!
I use this software to run my integrated graphics also via apple_set_os.efi. I set gpu-switch -d and changed the nvidia prime profile to the discrete graphics. after reboot I got a black screen just before login screen in ubuntu.
Do I have to just use gpu-switch without changing prime profiles? how do I prevent the black screen?
On my macbookpro6,1, if I set gpu-switch to -i and load Torchlight II, the system will use the integrated graphics.
But once I close the game, the system switches to discrete graphics automatically.
Not sure quite which other apps do this, but I had the graphics revert to auto a couple of times.
Due to this, I created a Launch Agent that triggers gpu-switch -i from time to time.
I'm wondering, is it possible to have gpu-switch running as a process that only activates when the graphics change to auto or discrete?
Anyway, thanks for this app, it helps quite a lot.
Dealing with a macbook pro 2011 with OSX 10.7.5, GPU is dead, can boot into single user mode (= integrated graphics is fine)
Computer does not have XCode, so I downloaded the precompiled version offered here:
https://github.com/0xbb/gpu-switch/releases/tag/macos-binaries
I used 7zip on my desktop because older mac doesn't support .tar.xz. I put the extracted files on a usb drive, mount the root with -uw, and mount the usb drive to the Macbook.
I follow documentation and cd to the build folder and run sudo ./gpu-switch -i
it appears to run but no output is given about success or failure (output would be helpful)
I sudo reboot.
The macbook reboots, and still tries to use the bad graphics card (blue lines -- unusable).
Am I missing a step? As a troubleshooting step I've reset the NVRAM several times.
ps thanks so much for this project, if it works it'll be a lifesaver!
I install gpu-switch correctly but after applying the fix the dedicated is still in used. Must I do something first to disable this and enable the intel card. I only have around 4 hr with the dedicated card.
Thank you
There is a fundamental flaw with both gpu-switch and the gfxCardStatus code that it was derived from:
When using integrated-only mode, this turns off the dynamic switching mode and places the machine in integrated graphics mode. However, when an app exits, OSX is switching the mode to discrete. When it does that it does not turn dynamic switching back on. So the machine will be stuck in discrete-only mode after that without manual intervention.
There is a fork of gfxCardStatus which handles this situation by detecting that when it happens and switching things back to integrated again. However that callback has been pruned out of gpu-switch, so gpu-switch is stuck with this problem as of now. You can see my fork of gfxCardStatus to see the code change that handles this issue.
In order for gpu-switch to handle this kind of situation it will need to be running as a daemon and monitor when the graphics system has switched to discrete in order to switch it back to integrated (if the user has requested integrated-only. In OSX this is handled with callbacks, not sure how it would be handled on windows or linux, but windows and linux may not be suffering from this problem of switching back to discrete when apps exist, I think probably not. So this may only be an issue on OSX.
After running this script to switch to the Intel graphics and restarting, Windows will fail to boot properly/completely until I use safe mode to switch back to the dedicated GPU. This happens in UEFI mode with both Windows 10 (build 17763) and Windows 8.1.
Hello!
With regards to:
sudo nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00
Does anyone know what the default setting for gpu-power-prefs
is?
Thank you so much!
-Ray
CPU has a constant load of about 10% on the system, from the System process after successfully using this patch. I Googled there were a lot of guys facing the same problem but no answers. Is there a solution to this bug? Some people said make macbook sleep and wake it up again solved the problem. I tried this 'solution', the CPU usage is normal but macbook uses NVidia card again (As a second Display and can't switch it to the first display again).
Switching: to dedicated GPU
error code was : 1
incorrect function
When I use the bat or exe I get the following message:
The program can't start because MSVCR120.dll is missing from your computer. Try reinstalling the program to fix this problem.
I have Visual C++ Redistributable Packages for Visual Studio 2013 installed, msvcr120.dll is inside system32 folder.
Macbook Pro 11.3
Windows 10 UEFI.
After running the .bat file in Admin mode this the error i get on Windows 10 64bit
C:\Users\El Capitan\Desktop\gpu-switch-windows\gpu-switch>gpu-switch.exe -i
Switching: to integrated GPU
Switching: Error
Error code was: 1
Error message was: Incorrect function.
C:\Users\El Capitan\Desktop\gpu-switch-windows\gpu-switch>pause
Press any key to continue . . .
Wanted to inform you that MacBook Pro 11,5 with AMD + Intel GPU works with
spoof_osx_version
MBPs older than 2012, need to install W10 in legacy BIOS mode (installed through DVD only).
Most of them have dedicated GPU broken (known issue).
W10 runs great, but cannot get integrated drivers to work.
Would be a great fix for us.
Thanks for any help.
I have Macbook Pro 8,2 (Early 2011) and I want to boot it using the integrated intel graphics. Whenever I try to run "./gpu-switch -i" as a root I get "Fatal: gpu-switch has to be run in EFI mode."
Please let me know how can get to EFI mode.
Thanks
When I run the provided "intergrated.bat" script, the command window says:
"AdjustTokenPrivileges failed
Error code was: 1300
Error message was:"
How to fix this?
Sorry for creating issue, but im not really understand how it works in general.
What i have is: MBP 2015 15", with windows 10 as second system
Case is: i stopped working, do 'Restart' in OSX, here should fire logout hook from osx folder (or i can set it with gfxCardStatus, doesnt matter)
It reloads into reFind, which has in config that special osx 10.9 emulation to start with intel enabled
So i load windows, it start loading, but picture stop refreshing at some time on windows logo and spinner, but windows keep working, i login to user, load autostart apps, i can change keyboard backlight... Its definitelly not blacksreen.
All i can do is holding power and booting again, till windows will be so kind to show me boot options and allow to boot in safe mode (stupid windows 10 ignore keys while loading)
In safe mode i just click 'Run as admin...' and reload again and it works like a charm.
So what i didnt get if setting intel from OSX should load windows normally and its a bug for me, or windows and osx scripts are different things, and its ok, then i always need to run in from windows in safe mode to make it work for windows?
Hi,
Thanks for doing the reverse engineering work for gpu-switch!
I have a MacbookPro11,5 which is booting to Linux 4.6.0-1amd64 by grubx64.efi
I'd like to use the integrated Intel graphics only.
Running gpu-switch -i
and rebooting, my system shows grub, and then
gives a black screen when starting Linux. The system boots okay - I can ssh to it.
lshw -c video
shows:
what# lshw -c video
*-display UNCLAIMED
description: VGA compatible controller
product: Venus XT [Radeon HD 8870M / R9 M270X/M370X]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:01:00.0
version: 83
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi vga_controller bus_master cap_list
configuration: latency=0
resources: memory:80000000-8fffffff memory:b0c00000-b0c3ffff ioport:3000(size=256) memory:b0c40000-b0c5ffff
which surprises me, because I thought the ATI GPU would be powered off,
and therefore not visible on the PCI bus.
Appologies if this is the wrong place to ask; I've found so much conflicting
information for different models, I'm very confused about what's applicable.
What's causing the black screen?
Should I try booting by Debian's EFIStub instead of via grubx64.efi?
Thank you,
No error, just big blue screen. Did any one get this setup working?
Hi all,
How do I install and load gpu-switch on the mac?
I downloaded and unzipped the gpu-switch-master.zip
Now can someone please tell me how to install and switch to integrated card?
It is unzipped to /Downloads/gpu-switch-master
Many thanks
When using the Integrated.bat or Dedicated.bat files it gives the warning:
The program can't start because MSVCR120.dll is missing from your computer. Try reinstalling the program to fix this problem.
I know the program is created for Windows 8 but thought i post it here for future reference, are there any plans on upping the compatibility for Windows 10?
I'm on a slow connection in peru, so installing Xcode just so I can build this is tricky. is there a binary that can be shared, downloaded?
Hello there !
Trying to revive a MacBookPro 6,2, I'm having the exact same issue as described in a previous thread (I commented it but decided to open a new issue when noticing it was closed).
./gpu-switch: line 44: printf: write error: Invalid argument
I'm intending to use OS X 10.11.6, so the fix to run Ubuntu on integrated graphics will obviously not work.
Thanks for your work and thanks in advance for your kind help.
Because my discrete gpu is broken, I cannot use gfxcardstatus to change to integrated card. Luckily, my 15inch MacbookPro early 2011 model works with this tool. Although the id after "gpu-power-prefs-" is different.
I just created this issue to report that so it may help other.
Thank you for this great tool!
When I try the command 'sudo ./gpu-switch -i', the following error shows up:
mount: /sys/firmware/efi/efivars: unknown filesystem type 'efivarfs'.
Fatal: Couldn't mount '/sys/firmware/efi/efivars'.
I am using MacBookPro 15,1 (Mid 2018), already tried using apple_set_os.efi / spoof_os_version = 10.9 under rEFInd
Would be really appreciated if someone can help.
thanks a lot, this works when i finally install rEFInd correctly(Installing rEFInd in recovery mode with binary code on Mac os, just as the rEFInd official website suggested)
I installed rEFInd on linux before, and it doesn't work, with just blank screen.
I'm so happy, cause my noisy fan get quiet finally.
THANKS AGAIN, man
Hi!
Since switching monitors with the nouveau driver is problematic, I've tried using the proprietary nvidia driver. Unfortunately, this disables the vgaswitcheroo method of shutting of the discrete (or the integrated) graphics card.
Have you had any success getting the discrete card to switch off using these drivers?
When I switch between nGPU and iGPU, the geforce gpu and fb is disconnect with power, how did that?
I have tested the purge-nvda
https://github.com/mayankk2308/purge-nvda
This help the nvidia-model macbook boot with iGPU and use the eGPU.
@0xbb @dwhinham @fiedl @sl33k @l1k
BUT importantly, the geforce gpu and fb is stilling consuming the power, even without geforce driver.
How do I anything to stop the geforce gpu and fb consuming the power, totally disuse the geforce card
references:
mayankk2308/purge-nvda#2
I look forward to receiving your replay!!!
Thanks!
Yours sincerely
Hi Bruno,
I am one of 33K+ 2011 Macbook Pro users with the unfortunate discrete GPU heat-induced solder connection failure. The MBP will always boot OSX in the single user mode, but unless all ATI/AMD GPU kexts are removed from ~/system/library/extensions/ folder, the MBP will freeze during normal OSX boot.
The brute removal of ATI/AMD GPU kexts causes the system to behave very slow, with graphic artifacts etc.
Based on your project, did you by chance find a way to disable initiation of the discrete GPU and boot OSX in such a way as if only Intel GPU was present? I know you are working on Linux, but if you know how to achieve this in OSX, great many people will be grateful to you. Please share what you know or think.
Thank you!
japush
I got this working on a MBP 2016 (13,3) : Dunedan/mbp-2016-linux#6 (comment)
Worthwhile to add a link and mention that this utility works with it too!
I would like a version of this that could switch GPUs before booting into an OS, if anyone wants to take a stab at that.
I have a MacBook Pro 11,5 and sometimes when I boot in macos de integrated card is switched to the discrete and I don't notice it.
When I reboot into arch how I can know wich card is enabled? Just to know if I have to reboot to change again the graphic card.
Hi my dedicated display card for macbook pro 8,2 was broken ..
I use ur gpu switch for windows runing well on window 8.1 on efi mode .. but now issue is macbook pro cannot load sound card and intergated display i use efi boot..
Can possible use legency boot to use intergated graphic?? To load windows ..
Hi there,
hope it is fine to post here. First of all: Thanks for your time you spend in this and make things possible for others. I really really appreciate this!
I use on my MacBook Pro 15" Mid-2017 a bootcamp & Windows Fall Creators Update Edition.
I remoed all drivers from the Bootcamp support software with the help of DDU and then ran integrated.bat which stated a success.
Afterwards, I boot into Windows by using the apple_set_os.efi trick and then select the windows partition to boot.
In device manager, I can see the Intel UHD 630 device being available (which is not the case as soon as the dedicated card is available).
I now have a constant flicker - sometimes it does not flicker for a couple of seconds, sometimes it does multiple times a second.
Any idea on this or even solutions?
Thanks in advance!
I initially stumbled across this site while looking for solutions to switch to intrigued graphics while running Windows 7 on my mac because it seems my nVidia GPU is failing. The driver crashes anytime I run a graphic intensive program (even Chrome), screen goes black for a bit then I get an error telling me the graphics card timed out and failed. Can't play any games because of the same issue. I have GFXCardStatus installed on my mac side(OSX 10.10.5) and that seems to work so I was looking for a similar solution for the windows side.
I upgraded to Windows 10 as I read that this fix will only work with Windows 8/10.
However I am having an issue getting the gpu to switch on Windows 10 with my MacBookPro 6,2. I can run the exe without errors, but when i try and run one of the .bat files I get an error that says it could not complete due to "error 1". Any idea why this is occurring?
One thing to add, in the windows how to section is says to check "Windows is using the MacBook's UEFI mode" my BIOS is listed as "legacy" not UEFI. How do I get it to run UEFI under Windows 10? Also I attempted to install the apple_set_os.efi even though this was for 11,3 MacBook Pros and while refind can recognize it on bootup it gives me an error saying it failed to run as well. Any ideas would be great, thank you!
Hello,
After setting to use integrated gpu with the script on Windows, if I boot into macOS and boot back to Windows, the gpu would not be switched and dedicated gpu would be in use.
Could you please point me to a solution or the cause for this problem? I am willing to make a little fork to address this issue if it's within my capacity.
Thank you for this tool. It's a lifesaver.
I can't find the exe file everywhere,no matter how hard I tried.the bat file won't work with out the exe.
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.