Ubuntu – How to turn off NVIDIA graphics on Macbook Pro

driversgraphicsmacbooknvidia

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.

Best Answer

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
Related Question