适用于 Macbook Pro 9,1 的 Nvidia 驱动程序

适用于 Macbook Pro 9,1 的 Nvidia 驱动程序

我目前在 Macbook Pro 9,1 上使用默认的 nouveau 驱动程序。我尝试安装 nvidia-current,但重启后 Ubuntu 就一片空白了。

有没有安全的方法来安装 nvidia 专有驱动程序?

答案1

我能够从 nvidia 页面安装 nvidia 驱动程序。只需获取 .run 文件中的驱动程序并安装即可。

命令如下:

sudo stop service lightdm
chmod +x NVIDIA-Linux-x86_64-331.49.run
sudo ./NVIDIA-Linux-x86_64-331.49.run

但是我发现我可以关闭 nvidia 并改用英特尔卡。考虑到我使用 MBP 主要用于工作和学习而不是玩游戏,英特尔卡比 nvidia 好得多。以下是我这样做的方法:

sudo vi /etc/grub.d/10_linux

+ Add following:
   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/"
after these lines:
   if [ x$type != xrecovery ] ; then
        echo "    gfxmode \$linux_gfx_mode" | sed "s/^/$submenu_indentation/"
   fi

   echo "    insmod gzio" | sed "s/^/$submenu_indentation/"

+ Rebuild grub:
grub-mkconfig > /boot/grub/grub.cfg

+ Open Grub Customizer, add following options:
i915.lvds_channel_mode=2 i915.modeset=1 i915.lvds_use_ssc=0

+ Reboot and enjoy low power and low heat

+ To confirm Nvidia is off:
sudo cat /sys/kernel/debug/vgaswitcheroo/switch

+ Download mbp_power.c and compile it:
sudo gcc -O2 -o /usr/local/bin/mbp_power mbp_power.c

+ Make it run right after resuming from sleep
vim /etc/pm/sleep.d/10_disable_nvidia.sh

case "${1}" in
    hibernate|suspend)
        # this is called when going to hibernate or to sleep
            ;;
    resume|thaw)
        # this is called when waking up
        /usr/local/bin/mbp_power
            ;;
esac

+ Make sure every thing is executable
chmod +x /usr/local/bin/mbp_power
chmod +x /etc/pm/sleep.d/10_disable_nvidia.sh

mbp_power.c:

// compile:
// sudo gcc -O2 -o /usr/local/bin/mbp_power mbp_power.c


#include <stdio.h> 
#include <sys/io.h>

#define PORT_SWITCH_DISPLAY 0x710
#define PORT_SWITCH_SELECT 0x728
#define PORT_SWITCH_DDC 0x740
#define PORT_DISCRETE_POWER 0x750

static int gmux_switch_to_igd()
{
    outb(1, PORT_SWITCH_SELECT);
    outb(2, PORT_SWITCH_DISPLAY);
    outb(2, PORT_SWITCH_DDC);
    return 0;
}

static void mbp_gpu_power(int state)
{
    outb(state, PORT_DISCRETE_POWER);
}

static void mb_gpu_print()
{
    printf("SELECT:  %hhu\n", inb(PORT_SWITCH_SELECT));
    printf("DISPLAY: %hhu\n", inb(PORT_SWITCH_DISPLAY));
    printf("DDC:     %hhu\n", inb(PORT_SWITCH_DDC));
    printf("POWER:   %hhu\n", inb(PORT_DISCRETE_POWER));
}

int main(int argc, char **argv)
{
    if (iopl(3) < 0) {
        perror ("No IO permissions");
        return 1;
    }
    int state=0;
    if (argc > 1) state = atoi(argv[1]);
    printf("Before:\n");
    mb_gpu_print();
    mbp_gpu_power(state);
    gmux_switch_to_igd();
    printf("After:\n");
    mb_gpu_print();
    return 0;
}

证明如下图所示: 在此处输入图片描述

相关内容