多显示器被禁用无法开启_Bumblebee下独显开启HDMI输出

53f589a7427eb8d18549d9bb1db3f692.png

关于Bumblebee,见这里:Bumblebee - ArchWiki

(中文版:Bumblebee (简体中文) ,但是中文版比较旧了,特别是关于HDMI输出那一段,还是建议参考上面英文版的为主)

对于Intel核显&NVIDIA独显的笔记本(甚至台式机),配置好bumblebee后,可以使用optirun来在独立显卡上运行程序,然后在核心显卡上输出,这样对于笔记本这种功耗敏感的设备,可以在不需要的时候关闭独显,达到节约能源的目的。不像NVIDIA官方驱动的prime-select,即完全切换显卡,要么用核显要么用独显,还需要重启xserver(且切换到核显的时候CUDA还不可用,独显似乎处于完全禁用状态)。而且bumblebee还有一个好处就是,就是在用核显渲染桌面的时候可以使用独显跑CUDA,互不影响(以前用官方的prime切独显跑CUDA的时候整个桌面卡得一逼,别说看视频刷网页,拖窗口都卡死)。

bumblebee的原理大致是在独显开启一个独立的xserver,然后在这个xserver上用一个看不见的VirtualGL或primus渲染程序,再传输到位于核显的xserver的xclient程序上显示。

(以上原理是我基于现象瞎猜的,因为我简单翻了下bumblebee和archlinux的wiki并没有找到相关原理的解释,如有错误欢迎纠正)

在bumblebee的xserver接管NVIDIA显卡后,原xserver并不能在独显上显示了,对于VGA/HDMI/DP接口连接到独显的双显卡笔记本来说,此时接口就没有任何信号输出了。因此开启独显的HDMI输出的思路就是把核显的画面输出到独显的xserver上。

bumblebee有个工具提供了这个功能:intel-virtual-output

当然如果直接运行,应该会报错 No VIRTUAL outputs on ":0"

需要新建配置文件 /etc/X11/xorg.conf.d/20-intel.conf

Section "Device"
    Identifier    "Intel Graphics"
    Driver        "intel"
    Option "VirtualHeads" "2"
EndSection

(最重要的是这条Option "VirtualHeads" "2",即在Intel核显上开启虚拟显示器)

如果还是No VIRTUAL outputs on ":0",可尝试将此配置文件写到/usr/share/X11/xorg.conf.d/20-intel.conf,反之亦然。

好了接下来要开启独显的HDMI输出了(此时用optirun运行程序,虽然独显的xserver启动了但HDMI是没有输出的)

/etc/bumblebee/xorg.conf.nvidia

在Section "Device"段

    Option "NoLogo" "true"
    Option "UseEDID" "true"
    #Option "UseDisplayDevice" "none"
    Option "AllowEmptyInitialConfiguration"
    #Option "ConnectedMonitor" "DFP"

在Section "ServerLayout"段

    Option      "AutoAddDevices" "true"
    Option      "AutoAddGPU" "false"

(如果还是不行,可以尝试把Option "ConnectedMonitor" "DFP"这条打开,可以强制让系统认为你连接了一个显示器,如果工作正常建立注释掉,否则拔出HDMI后这个显示器还存在,显示设置不会自动恢复)

以下是我整个xorg.conf.nvidia内容,不建议完全复制,还是按自己的情况来修改,免得翻车:

Section "ServerLayout"
    Identifier  "Layout0"
    Option      "AutoAddDevices" "true"
    Option      "AutoAddGPU" "false"
EndSection

Section "Device"
    Identifier  "DiscreteNvidia"
    Driver      "nvidia"
    BusID       "PCI:01:00:0"
    VendorName  "NVIDIA Corporation"

#   If the X server does not automatically detect your VGA device,
#   you can manually set it here.
#   To get the BusID prop, run `lspci | egrep 'VGA|3D'` and input the data
#   as you see in the commented example.
#   This Setting may be needed in some platforms with more than one
#   nvidia card, which may confuse the proprietary driver (e.g.,
#   trying to take ownership of the wrong device). Also needed on Ubuntu 13.04.
#   BusID "PCI:01:00:0"

#   Setting ProbeAllGpus to false prevents the new proprietary driver
#   instance spawned to try to control the integrated graphics card,
#   which is already being managed outside bumblebee.
#   This option doesn't hurt and it is required on platforms running
#   more than one nvidia graphics card with the proprietary driver.
#   (E.g. Macbook Pro pre-2010 with nVidia 9400M + 9600M GT).
#   If this option is not set, the new Xorg may blacken the screen and
#   render it unusable (unless you have some way to run killall Xorg).
    Option "ProbeAllGpus" "false"

    Option "NoLogo" "true"
    Option "UseEDID" "true"
    #Option "UseDisplayDevice" "none"
    Option "AllowEmptyInitialConfiguration"
    #Option "ConnectedMonitor" "DFP"
EndSection

Section "Screen"
    Identifier "Default Screen"
    Device "DiscreteNvidia"
EndSection

Bumblebee配置 /etc/bumblebee/bumblebee.conf

KeepUnusedXServer=true

(这个是在bumblebee中没有程序运行时还保持着独显的xserver开启)

PMMethod=none

(官方建议把电源管理关掉,但是我PMMethod=bbswitch开着好像也没事?)

(反正我不关(逃

好了此时把显示器连接到独显上的HDMI/VGA/DP接口,

此时可以先试试optirun一个程序,看看HDMI接口有没有反应(正常输出黑屏)。

如果报错 error: [XORG] (EE) Failed to load module "mouse"

sudo apt install xserver-xorg-input-mouse

(对了,此时export DISPLAY=:8可以直接在这个黑屏的xserver上运行程序,嘿嘿(抖个机灵

(Emmm不过此时这个外屏上的xserver的输入非常诡异,和主xserver共享键盘鼠标,同时反应Emmmmmm自己脑补/体会

运行intel-virtual-output(其实没必要optirun也没必要sudo),如果正常外部显示器会有输出,并且在当前xserver能识别到第二个显示器(比如用GNOME,可以在设置里面配置显示设置啦,比如是镜像还是扩展)

c224328e9eef9c5d6b5955d666c6478a.png
扩展模式笔记本内屏

c3dc590c6e2e2abedf34702d81099166.png
扩展模式外屏(Emmm这是个很老很经典的CRT显示器,三星788DF,手上没有其它显示器来测试了,只好HDMI转VGA干他)

——————我是分割线——————

下面介绍个骚操作,可以通过export DISPLAY=:8(独显上的xserver是:8)来使程序直接运行在独显上:

开!始!表!演!

首先现在两块显示屏是镜像模式,然后在:8上跑glxgears,可以看到笔记本内屏没有反应,外屏上直接覆盖了一个窗口

6d70d666d1e017d6232d05de51dafd54.png
连接核显的内屏没有东西

de2f58e4a68c9e7dc0f4202d6140dc02.png
说明用intel-virtual-output下输出,外部屏幕仍是个独立的xserver,且还能在上面覆盖窗口

可以用这个方法直接在独显运行性能敏感的3D程序,直接在独显输出,从玄学的角度来说可以提高性能,否则还是optirun的话...

bea23e78e3c18c9a01188ad26cfde63a.png
独显渲染-->核显输出-->独显输出......

(当然如果只需要独显我觉得最好的方法还是直接把lightdm跑在:8上了

(另外,上文提到了这个:8 xserver的输入方式很诡异.......如果真在上面玩游戏的话......不知有什么好的优化方法,各位大佬提提建议

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值