How to turn off NVIDIA graphics on Macbook Pro?

11,183

I happen to have the exact same computer as you. What I devised is to add a few lines to grub to disable the discrete graphics at the efi level:

$ cat /etc/grub.d/10_linux
# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
    echo "    load_video" | sed "s/^/$submenu_indentation/"
else
    if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
        echo "        load_video" | sed "s/^/$submenu_indentation/"
    fi
fi
if ([ "$ubuntu_recovery" = 0 ] || [ x$type != xrecovery ]) && \
    ([ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 1 ]); then
    echo "    gfxmode \$linux_gfx_mode" | sed "s/^/$submenu_indentation/"
fi

echo "        outb 0x728 1" | sed "s/^/$submenu_indentation/"
echo "        outb 0x710 2" | sed "s/^/$submenu_indentation/"
echo "        outb 0x740 2" | sed "s/^/$submenu_indentation/"
echo "        outb 0x750 0" | sed "s/^/$submenu_indentation/"

echo "        insmod gzio" | sed "s/^/$submenu_indentation/"
echo "        if [ x\$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi" | sed "s/^/$submenu_indentation/"

I just added the outb lines in between the insmod gzio and linux_gfx_mode. For reference:

outb 0x728 1 # Switch select
outb 0x710 2 # Switch display
outb 0x740 2 # Switch DDC
outb 0x750 0 # Power down discrete graphics 

This disables the graphics at the pcie-link level, such that it vanishes from the system. Unlike macOS, the IronLake Intel HD Graphics can drive the external display output, but without audio.

What you described as the mac disabling igpu unless booting macOS holds true for any mac made after 2010, or any mac with a Sandy Bridge chip or later. (2010=nehalem, 1st gen 45nm.) The apple_set_os.efi trick does not work before 2011 (pre-2011, at the time, anything booted with efi would behave exactly like macOS, efi didn't check the OS, just that it was booted natively, enabling the integrated graphics. And the only way to boot an OS with igpu disabled was to legacy boot, which we are not doing) I tried running it, and it prints that the apple_set_os protocol was not found. I run 16.04.3 stable and it is such a nice experience once you can use the computer without crashes.

About the nvidia proprietary drivers: I did some opengl testing with dolphin-emu and DRI_PRIME=1 booting without outb 0x750, therefore disabling the dGPU's connection to the lvds display, but leaving it available headless for rendering. Nouveau and proprietary have nearly the same performance. (in fact, the majority of edge cases here were won by nouveau) The NV50/Tesla architecture is perhaps the best supported by nouveau. Therefore, I would actually recommend staying on nouveau.

Lastly, to enable intel graphics on boot permanently (as long as nvram variables are not erased) you can do this from linux:

mount -t efivarfs rw /sys/firmware/efi/efivars/ # make sure efi is mounted
sudo bash -c 'printf "\x07\x00\x00\x00\x01\x00\x00\x00" > /sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9'

You can also accomplish the exact same thing from macOS as well:

sudo nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00
Share:
11,183

Related videos on Youtube

theV0ID
Author by

theV0ID

Updated on September 18, 2022

Comments

  • theV0ID
    theV0ID over 1 year

    I have a Macbook Pro from 2010 that has NVIDIA graphics and Intel integrated agraphics:

    $ lspci|grep -i vga
    00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 12)
    01:00.0 VGA compatible controller: NVIDIA Corporation GT216M [GeForce GT 330M] (rev a2)
    

    When I install the propritary NVIDIA driver (340.76), the system hangs when I start the X-server. I've been told that this is because the NVIDIA driver doesn't support the special hardware characteristics of the Macbook.

    So I would like to turn the NVIDIA graphics off completely and only use the Intel integrated graphics instead, because the battery only holds for ~1,5 hours when doing office work since I installed Ubuntu. It held for about 3 hours with Mac OS when doing similiar work.

    I've read of two ways of doing that:

    1. Turning off the discrete graphics device in the BIOS
    2. or switching to integrated graphics in nvidia-settings.
    3. UPDATED: Booting into OS X and forcing the integrated graphics in gfxCardStatus 2.2.1.

    First method won't work for me because there is no BIOS on Macbooks. The second method won't work either because I cannot install the propritary drivers, as described above.

    Its a basically fresh installation of Ubuntu 14.04 without any tweaks worth mentioning.

    UPDATE: After reading lots of documentation I've came to the conclusion that this only is possible by using method 3 on Macbook Pro, i.e. one must still have OS X installed, which I haven't! This is really shitty, because it means that I have no chance to turn off the NVIDIA GPU.

    • Pilot6
      Pilot6 over 8 years
      Which Nvidia drivers did you install and how?
    • theV0ID
      theV0ID over 8 years
      @Pilot6: I iinstalled the drivers by activating the recommended propritary driver in the propritary drivers dialog.
    • Pilot6
      Pilot6 over 8 years
      Which one? The number?
    • theV0ID
      theV0ID over 8 years
      @Pilot6: 340.76
  • theV0ID
    theV0ID over 8 years
    I already tried that driver version, it made my Macbook hang, as described. You sure that this is the correct driver also for Macbook Pro's gmux-based hardware?
  • Pilot6
    Pilot6 over 8 years
    This is the correct driver for this nvidia adapter. You can try nvidia-331 too.
  • theV0ID
    theV0ID over 8 years
    I was asking about the specific Macbook hardware. I seriously doubt that nvidia-340 doesn't support gmux but an older version does.
  • nenchev
    nenchev over 6 years
    the apple_set_os.efi is used to trick the macbook into powering on the integrated graphics when you're not in macOS. He clearly already has the integrated graphics powered on.