1. 程式人生 > >使用 Bumblebee 控制 NVIDIA 雙顯示卡

使用 Bumblebee 控制 NVIDIA 雙顯示卡

簡介

Nvidia的雙顯示卡切換技術叫Optimus(擎天柱),可惜只能在win7、vista下實現。Linux下沒有對應的技術,當然蘋果也沒有。這導致獨立顯示卡一直在啟用,顯示卡發熱升溫,風扇狂轉,卻沒有正常工作輸入。平時筆記本電池在 Win7 能使用4小時,到了 Ubuntu 兩個小時左右就耗光了。AMD早已經為ATI顯示卡開發出Linux下的催化劑,支援A卡與intel集顯之間切換,N卡的使用者只能嘴饞。


Optimus 技術是不依賴於硬體複雜結構的交火顯示卡實現。獨立顯示卡按需渲染,並傳輸給整合顯示卡,整合顯示卡則負責顯示功能。當筆記本通過電源供電時,獨立顯示卡將關閉,以延長電池壽命。


Bumblebee 試圖模擬 Optimus 技術的行為;當需要的時候,使用獨立顯示卡進行渲染,不使用的時候則關閉。當前的版本僅支援按需渲染,電源管理功能仍然在開發之中。

測試環境:

Acer Aspire 5750G
NVIDIA GeForce GT630M
ubuntu 12.04 x86_64 / archlinux x86_64

一、更新顯示卡資訊,否則可能識別出錯

➜  ~  sudo update-pciids
[sudo] password for congbo:
Downloaded daily snapshot dated 2012-09-06 03:15:02

二、檢視顯示卡資訊

更新前:

➜  ~  lspci | grep -i 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 Device 0de9 (rev a1)

更新後:

➜  ~  lspci | grep -i 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 GeForce GT 630M (rev a1)

更新後正確識別出了顯示卡型號。

Nvidia 卡資訊的末尾不是 rev ff,表示獨顯是開啟的。

三、拔下電源介面卡,檢視功耗

➜  ~  grep rate /proc/acpi/battery/BAT0/state
present rate:            2613 mA

平均2000左右

四、安裝bumblebee

sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia

加入bumblebee組

sudo usermod -a -G bumblebee $USER

ubuntu 在安裝過程中會將當前使用者加入bumblebee組,登出或重啟後生效

複製程式碼
➜  ~  grep congbo /etc/group
adm:x:4:congbo
cdrom:x:24:congbo
sudo:x:27:congbo
dip:x:30:congbo
plugdev:x:46:congbo
lpadmin:x:109:congbo
congbo:x:1000:
sambashare:x:124:congbo
bumblebee:x:1001:congbo
複製程式碼

bumblebee 版本:

➜  ~  bumblebeed --version
bumblebeed (Bumblebee) 3.0.1
Copyright (C) 2011 The Bumblebee Project
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

五、測試效果

➜  ~  lspci| grep -i 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 GeForce GT 630M (rev ff)

Nvidia 卡資訊的末尾是 rev ff,表示獨顯已經關閉。

再次拔下電源介面卡,檢視功耗。

➜  ~  grep rate /proc/acpi/battery/BAT0/state
present rate:            1523 mA

平均1000左右,2000->1000,風扇以前一直狂轉,現在基本沒動靜。

bumblebee的作用是禁用nvidia獨立顯示卡,需要使用獨顯時,使用”optirun 程式名“手動開啟nvidia來執行需要加速的程式,如optirun vmware。

集顯、獨顯分別執行 glxgears 或 glxspheres 測試,以glxgears為例:

➜  ~  glxgears
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
301 frames in 5.0 seconds = 60.107 FPS
300 frames in 5.0 seconds = 59.869 FPS
300 frames in 5.0 seconds = 59.856 FPS
➜  ~  optirun glxgears
2284 frames in 5.0 seconds = 456.677 FPS
2358 frames in 5.0 seconds = 471.540 FPS
2275 frames in 5.0 seconds = 454.942 FPS

開啟N卡設定:

optirun nvidia-settings -c :8

tips:

現在i系列的一般都是雙顯示卡配置,請勿自行安裝nvidia驅動。雙顯示卡的機器,必須停止整合顯示卡才能正確安裝nvidia驅動。
不要用root使用者執行,最好是用sudo執行。
如果安裝失敗,可能無法進入任何一個介面,包括文字介面。解決辦法,固定該主機IP,開啟ssh服務,確保可以在區域網的另一臺主機ssh進該主機。之後然後再折騰,如果失敗,ssh進該主機,解除安裝掉nv的驅動(sudo apt-get autoremove nvidia-current),然後重啟。
雙顯示卡桌上型電腦折騰這個的時候注意把顯示器連線到主機板的輸出埠上,否則沒用。
安裝好以後 , “系統->系統管理->NVIDIA X Server Settings“ 不要亂動。

有的bios裡可以關掉獨顯,桌面渲染3D等,i卡能夠勝任。(i卡虛擬機器裡執行win7無法開啟aero特效)

NVIDIA Optimus獨顯集顯切換將支援Linux

NVIDIA的Optimus技術可讓筆記本根據效能需要在英特爾整合顯示卡和NVIDIA獨顯之間自動切換,節省電力。但這項技術不支援Linux。2個多月前,Linux作者Linus Torvalds在芬蘭的一個活動中因此對NVIDIA豎起了中指。現在,NVIDIA工程師透露他們正致力於實現Linux支援。NVIDIA的Aaron Plattner在郵件列表上,他已經在新的Linux版驅動上概念驗證了Optimus,未來Linux筆記本使用者有望獲得Optimus支援。

參考: