
双显卡,相信大家都不会感到陌生。这是一种将两块显卡(集成—独立、独立—独立)通过桥接器桥接,协同处理图像数据的工作方式。
双显卡一般是在平时运行普通应用时将少量的运算和屏幕输出交给集成在CPU中功耗较低的核芯显卡进行,将独显关闭以达到节能的目的;当需要大量的GPU运算如游戏或解码,则开启独立GPU进行,满足性能的需求。近几年的笔记本,基本上采用了这种模式。
真正要在两者之间达到平衡,则需要配合系统和切换软件进行调度。nVIDIA在Windows系统下的切换软件叫Optimus,即擎天柱。
很可惜的是,在Linux平台下没有nVIDIA官方提供的切换软件,所以很多人笔记本装了Linux后发现独显一直开着,耗电极速上升。虽然可以在BIOS里将独显关闭,但是这样就意味着花钱买的这块显卡彻底用不上了。
程序员天生就是来解决问题的,官方不干我们自己来,开发出了Linux的Optimus,叫做Bumblebee(大黄蜂).
Bumblebee and Optimus,好冷的笑话 ~
于是,为装Linux的双显卡笔记本装Bumblebee成了很有必要的一件事。
以下是正文 ~(观众:扯了这么久才到正文是在闹哪样!)
1 2 3 4 |
#sudo add-apt-repository ppa:bumblebee/stable #sudo apt-get update #sudo apt-get install bumblebee bumblebee-nvidia #sudo reboot |
可以用了,bumblebee什么都设置好了,不用你操心了 ~
1 2 3 4 5 6 7 |
#lspci |grep VGA //输出: 00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) 01:00.0 VGA compatible controller: NVIDIA Corporation GF108M [GeForce GT 550M] (rev ff) //(rev ff)表示独立显卡已关闭 |
独立显卡关闭意味着我们目的达到了一半,要实现切换意味着我们还要能打开:
1 2 3 4 5 6 7 8 |
//语法:$ optirun [options] <application> [application-parameters] $ optirun 程序名 //例如运行firefox $ optirun firefox //运行选项 $ optirun --help |
1 |
$ optirun nvidia-settings -c :8 |
1 2 3 4 5 |
//集显 #glxgears //独显 #optirun glxgears |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//For advanced users, if you do not want to use the proprietary //nvidia driver or 32-bit libraries (for example, if you are only //interested in power savings), you can do your custom installation. //Minimal setup,即最小化安装 : #sudo apt-get install --no-install-recommends bumblebee //Depending on your needs, add to this line,根据需要添加: bumblebee-nvidia //proprietary nvidia driver support (if installed, become default over nouveau) virtualgl //VirtualGL as backend virtualgl-libs-ia32 //32bit support for VirtualGL on 64bit system, necessary to run 32bit app through optirun primus //primus/primusrun as backend (virtualgl Stays default, you need to run optirun -b primus <app>) primus-libs-ia32 //32bit support for primus/primurun on 64bit system, necessary to run 32bit app through optirun |
1 2 3 4 5 6 7 8 9 10 11 |
//Uninstall //If you're unsatisfied with Bumblebee, you can remove it via: #sudo apt-get install ppa-purge #sudo ppa-purge ppa:bumblebee/stable //If you want to keep some programs from the bumblebee repository, //you can also suffice by removing Bumblebee only (including its //dependencies): #sudo apt-get purge bumblebee #sudo apt-get --purge autoremove |
):虽然不难,但我还是累觉不爱了。你看APU+AMD倒是多么轻松愉快。
然后我现在补充一些关于intel+AMD组合的解决方案,希望对一些用户有帮助。
方案是用开源驱动,通过vgaswitch进行切换。网友分享的方案,详见参考资料。
准备工作:安装了ATI闭源驱动的请先卸载;在BIOS里禁用了双显卡切换的请先开启。
1 2 3 4 5 6 7 |
//首先在终端下执行这条命令: #sudo cat /sys/kernel/debug/vgaswitcheroo/switch //如果类似这样(主要是两个状态都是Pwr): 0:IGD:+:Pwr:0000:00:02.0 1:DIS: :Pwr:0000:01:00.0 //就说明你的两块显卡都开着,那么就按照下面的步骤做吧 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
//建立一个脚本/usr/local/sbin/vgaswitcher #!/bin/bash if [ "$(whoami)" != "root" ]; then echo "Use as root" exit 1 fi if [ -z "$1" ]; then cmd="OFF" else if [ "$1" = "-i" ]; then cmd="DIGD" elif [ "$1" = "-d" ]; then cmd="DDIS" else cmd=$1 fi fi if ([ "$cmd" != "OFF" ] && [ "$cmd" != "DDIS" ] && [ "$cmd" != "DIGD" ]); then echo "Bad Command!" exit 1 fi echo "$cmd" > /sys/kernel/debug/vgaswitcheroo/switch cat /sys/kernel/debug/vgaswitcheroo/switch //然后再建立一个启动脚本/etc/init.d/vgaswitch #!/bin/bash if [ "$1" != "start" ]; then exit; fi /usr/local/sbin/vgaswitcher #/usr/local/sbin/vgaswitcher -i //注释掉这句的原因是, //在Ubuntu 11.10上使用正常, //在Ubuntu12.04系统上,首次建立文件时使用正常, //后来更改了些服务,有了这句话反而无法禁用独显了 //都建立好以后,执行如下命令: #sudo chmod +x /usr/local/sbin/vgaswitcher /etc/init.d/vgaswitch && sudo update-rc.d vgaswitch defaults //重启就可以禁用掉独显了~ |
1 2 3 4 5 6 7 8 |
//再次执行最开始的命令来查看状态: #sudo cat /sys/kernel/debug/vgaswitcheroo/switch //现在应该是这样了(一个Pwr,另一个Off): 0:IGD:+:Pwr:0000:00:02.0 1:DIS: :Off:0000:01:00.0 //这样就好了~ |
1 2 3 4 5 6 7 8 9 10 |
//另外一种更简便的方法: //在/etc/rc.local文件的exit 0之前添加以下语句: echo IGD > /sys/kernel/debug/vgaswitcheroo/switch #切换到集成显卡 echo OFF > /sys/kernel/debug/vgaswitcheroo/switch #关掉没有连接的其它显卡 //ps:sudo gedit /etc/rc.local //可以使用以上提到的查看显卡的命令查看显卡状态: #sudo cat /sys/kernel/debug/vgaswitcheroo/switch |
参考资料
Bumblebee – Ubuntu Wiki
The Bumblebee Project Wiki
12.04/12.10 Nvidia双显卡Bumblebee攻略 – Ubuntu中文论坛
双显卡笔记本ubuntu下禁用独显 – 开源中国
本文链接地址: Bumblebee – Linux 下的 nVIDIA Optimus
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
如果您愿意为文章的内容或想法提供支持,欢迎点击下边的捐赠按钮,资助作者创作更多高价值高品质的内容。