Ubuntu 16.04 上的双 GPU 配置

Dual GPU configuration on Ubuntu 16.04

Objective:

在两个相同的 GPU 上使用多显示器扩展显示。

硬件:

软件:


测试程序

1) 硬件测试

2) 软件测试


正在尝试我的 objective

我已尝试使用 xorg.conf 文件进行多种配置。 我得到最多尝试的最接近成功的是:

xorg.conf 文件:

#xorg.file for 6-screen, 2-GPU setup

###############################################################
# Mouse Configuration options
Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection


# Keyboard Configuration options
Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

###############################################################
# Monitor Configuration options
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor2"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor3"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor4"
    VendorName     "Dell, Inc."
    ModelName      "DELL E2009W"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor5"
    VendorName     "Dell, Inc."
    ModelName      "DELL E2009W"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

################################################################
# GPU Configuration options
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:1:0:0"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:2:0:0"
EndSection

################################################################
# device & monitor bindings configuration options
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    Monitor        "Monitor1"
    Monitor        "Monitor2"
    Monitor        "Monitor3"
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor4"
    Monitor        "Monitor5"
    Option         "Stereo" "0"
    Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+1050, DVI-D-0: nvidia-auto-select +3360+1050"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

#############################################################
# Xinerma & Compsite extensions
Section "Extensions"
    Option         "Composite" "Disable"
EndSection

##############################################################
# Screen bindings configuration options
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 1050
    Screen      1  "Screen1" Above "Screen0"

    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

    Option         "Xinerama" "1"
EndSection

###########################################################
# Unused section
Section "Files"
EndSection

澄清

不是无限登录循环问题。 无限登录循环是我问题的症状。

有几个无限循环question/answers,那些假设你犯了一个错误并想"fix"通过重置为默认值来解决问题。这里有几个重置为默认“修复”的问题,这不是我的问题。

不想重置为默认值,并且可以return我的系统在每次尝试后都可以在一张显卡上工作。我在问如何进一步改变 settings/configurations 以达到我的目标(没有登录循环)?

我最近有机会做一些非常相似的事情:2 个 Nvida GPU, 每个驱动3个显示器。过程中发现的一些东西 让它工作是:

  1. 如果您从单个 GPU 驱动多个显示器,您将 每个头都需要一个设备部分,每个设备部分 需要一个 'Screen number' 选项,其中 'number' 从 0 到 1 少于连接的显示器数量。

  2. 我认为您需要为每台显示器设置一个屏幕部分。来自 xorg.conf 手册页:'“屏幕”表示图形的绑定 设备(设备部分)和监视器(监视器部分)。'

  3. ServerLayout中Screen选项中的screen-num参数 部分与屏幕中的屏幕号参数无关 设备部分中的选项。

我在调试 X windows 配置时发现有用的东西 问题是在多用户模式下启动系统(在 早期启动屏幕中的内核参数),创建一个简单的 .xinitrc 文件(比如,只有 'xterm' 这一行(假设你有 xterm 安装)),然后用 'startx' 启动 X。然后,如果(当)它 失败,您将能够查看 /var/log/Xorg.0.log 中的日志文件, 更改 xorg.conf,然后重试。

我对您的 xorg.conf 文件进行了一些编辑。我注释掉了一些选项 在屏幕部分,因为它们将取决于您的本地端口 名称,您肯定会想要更改屏幕的方式 安排在 ServerLayout 部分。

我希望您可以以此为基础来进行工作设置。它是 烦人,因为一切都必须恰到好处才能正常工作 全部.

#xorg.file for 6-screen, 2-GPU setup

###############################################################
# Mouse Configuration options
Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection


# Keyboard Configuration options
Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

###############################################################
# Monitor Configuration options
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor2"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor3"
    VendorName     "Dell, Inc."
    ModelName      "DELL E207WFP"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor4"
    VendorName     "Dell, Inc."
    ModelName      "DELL E2009W"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

Section "Monitor"
    Identifier     "Monitor5"
    VendorName     "Dell, Inc."
    ModelName      "DELL E2009W"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
EndSection

################################################################
# GPU Configuration options
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:1:0:0"
    Screen         0
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:1:0:0"
    Screen         1
EndSection

Section "Device"
    Identifier     "Device2"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:1:0:0"
    Screen         2
EndSection

Section "Device"
    Identifier     "Device3"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:2:0:0"
    Screen         0
EndSection

Section "Device"
    Identifier     "Device4"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:2:0:0"
    Screen         1
EndSection

Section "Device"
    Identifier     "Device5"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 970"
    BusID          "PCI:2:0:0"
    Screen         2
EndSection

################################################################
# device & monitor bindings configuration options
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen2"
    Device         "Device2"
    Monitor        "Monitor2"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen3"
    Device         "Device3"
    Monitor        "Monitor3"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen4"
    Device         "Device4"
    Monitor        "Monitor4"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


Section "Screen"
    Identifier     "Screen5"
    Device         "Device5"
    Monitor        "Monitor5"
    Option         "Stereo" "0"
    #Option         "nvidiaXineramaInfoOrder" "DFP-0"
    #Option         "metamodes" "DVI-I-1: nvidia-auto-select +1680+0, HDMI-0: nvidia-auto-select +3360+0, DP-1: nvidia-auto-select +5040+0, DVI-D-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection


#############################################################
# Xinerma & Compsite extensions
Section "Extensions"
    Option         "Composite" "Disable"
EndSection

##############################################################
# Screen bindings configuration options
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 1050
    Screen      1  "Screen1" Above "Screen0"
    Screen      2  "Screen2" Above "Screen1"
    Screen      3  "Screen3" Above "Screen2"
    Screen      4  "Screen4" Above "Screen3"
    Screen      5  "Screen5" Above "Screen4"

    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

    Option         "Xinerama" "1"
EndSection

###########################################################
# Unused section
Section "Files"
EndSection

好的,我通过广泛的研究和测试回答了我的问题。如果你有一个多 gpu、多显示器系统,你想要一个统一的桌面(这意味着 windows 捕捉到显示器,并且可以拖动程序 windows 跨显示器,无论哪个显示器在哪个 gpu 上).那么简短的回答是 SLI/base Nvidia 显卡的 Mosaic。

但是,除非您花费 60 多个小时阅读文档并与他人交谈(我就是这样做的),否则会丢失多个信息点。

我将提供多个链接和说明点,以帮助其他人解决挫折和努力。从 Ubuntu 16.04、Unity DE、Nvidia Geforce 驱动程序 v380+ 的角度理解所有命令和建议,可能不适用于其他系统和硬件。


Nvidia --> X 服务器和 RandR

之间有几个[错误]沟通点
  • RandR(本机安装的显示管理器,在 CLI 中也称为 xrandr)
  • X server(输入和输出之间的主要 management/connection 系统,包括 Xorg,xorg.conf 方面)
  • Nvidia-settings(Nvidia 的显示管理器,向 X 服务器和 RandR 发送信息)

使用 nvidia-settings 时,Nvidia 将配置错误信息并将其发送到 x 服务器和 RandR,然后在内部自行处理逻辑。

  1. Nvidia 有自己的 xinerama,与 X 服务器 xinerama 分开。如果你在 xorg.conf 文件中启用 xinerama,那是 X 服务器自己的 Xinerma 而不是 Nvidia 的(所以如果你试图通过 nvidia-settings.

  2. Nvidia 会将所有显示器置于 1 个屏幕下,并将此屏幕作为统一桌面呈现给 X 服务器,同时使用其内部 xinerama 逻辑允许 RandR 正确查看单独的显示器。

    • 这意味着在 xorg.conf 中制作单独的屏幕、监视器、设备部分正在打破 nvidia-settings 管理桌面的自然方式(即禁用 Nvidia 的内部 xinerama)。结果,这将要求在 xorg.conf 文件中启用 X 服务器的 xinerama(但这往往会破坏我在开头提到的统一桌面期望之一)。
    • 即使在处理多个 gpus 来渲染桌面时,它仍然向 X 服务器显示为 1 个屏幕,同时使用其内部逻辑向 RandR 报告所有可用的显示器。这将需要一个名为 base/SLI Mosaic 的选项,但我也需要在下面说明这一点。

Nvidia 结束 --> RandR & X 服务器解释


英伟达 --> xorg.conf

Nvidia 如何使用 xorg.conf 文件并不反映您在 X server, X org, and xorg.conf documentation. Instead you need to focus on reading Nvidia 文档中阅读的内容。但是,当您查看文档时请注意 URL 。 '/README/' 之前的数字需要是您的 Nvidia 驱动程序版本号,在下面的示例 URL 中为 '390.42'。对 nvidia-settings 文档的许多 google 命中对于旧驱动程序来说确实是旧文档。如果您获得旧文档,这将使您陷入困境。 示例:

http://us.download.nvidia.com/XFree86/Linux-x86_64/390.42/README/index.html

  1. 如前所述,Nvidia 仅向 X 服务器报告单个屏幕。在这里,我将向您展示 xorg.conf 文件的 Section "Screen" 示例以进行说明。

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "GPU-0.DFP-0: nvidia-auto-select +0+0, 
                                GPU-0.DFP-4: nvidia-auto-select +1680+0, 
                                GPU-1.DFP-0: nvidia-auto-select +3360+0, 
                                GPU-1.DFP-4: nvidia-auto-select +5040+0, 
    Option         "MultiGPU" "Off"
    Option         "SLI" "on"
    Option         "BaseMosaic" "on"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection 
  • 如您所见,它仍然是一个屏幕,但 metamode 可以是特定的 要使用哪个 gpu 和端口。
  • 还有一点就是MultiGPU不是指你主板上的显卡数量
  • nvidia-auto-select 负责您的水平同步、垂直刷新范围、显示器分辨率,但正如您从用于显示器放置的尾随数字中看到的那样,我期待它会将我的系统分辨率设置为 1680x1050。

一个比较明确的Section Screen是:


Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "Stereo" "0"
    Option "nvidiaXineramaInfoOrder" "DFP-0"
    Option "metamodes" "GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.DVI-I-1: nvidia-auto-select +0+0, 
                        GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.DVI-D-0: nvidia-auto-select +1680+0, 
                        GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.DVI-I-1: nvidia-auto-select +3360+0, 
                        GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.DVI-D-0: nvidia-auto-select +5040+0"
    Option "MultiGPU" "Off"
    Option "SLI" "on"
    Option "BaseMosaic" "on"
    SubSection "Display"
        Depth 24
    EndSubSection
EndSection
  • 通过添加 GPU 哈希,您可以直接说明要使用哪些显卡,而不是将其留给系统来解释。
  • 在我的系统上,DVI-D-0 == 到 DFP-4,因此系统没有任何解释,但我认为使用端口类型而不是 DFP 放置可以消除歧义用户。

Nvidia 结束 --> xorg.conf


SLI/Base 马赛克捕捉 22

所以最终的答案是在使用 nvidia-settings 我想要的统一桌面时需要 SLI Mosiac。但是,如果它们 不是 Quadro 或 NVS selected GPU,它将只允许在 2 个或更多 GPU 上启用三个屏幕家庭。这不是因为我珍贵的 Geforce GTX 970 的技术无法处理它,而是因为 Nvidia 在 nvidia-settings 代码中人为地限制了它以推广他们更新的 GPU。我可以从测试存储库中的 Nvidia forum, and from looking at the source 代码中注意到这一点。

事实上,最初您可以在 2 个非 selected GPU 上拥有超过 3 个屏幕,直到 296 个驱动程序强制更改。

如果您在没有合适的 GPU 的情况下仍然尝试,它将导致所有屏幕同时显示在 RandR GUI 和 Nvidia 设置 GUI 中。但是,您会注意到除三台显示器外的所有显示器都将被禁用,并且只有在您禁用已启用的 3 台显示器中的一台时才能启用它们。


有用的命令

xrandr --version
xrandr --listproviders
sudo Xorg -version
sudo lspci -vvv |grep -i -A 20 nvidia
nvidia-smi
nvidia-xconfig --query-gpu-info
nvidia-settings
cat /var/log/Xorg.0.log
nvidia-xconfig -t

功能齐全 xorg.conf

Section "ServerLayout"
     Identifier "Layout0"
     Screen 0 "Screen0" 0 0
     InputDevice "Keyboard0" "CoreKeyboard"
     InputDevice "Mouse0" "CorePointer"
     Option "Xinerama" "0"
EndSection

Section "InputDevice"
    Identifier "Mouse0"
     Driver "mouse"
     Option "Protocol" "auto"
     Option "Device" "/dev/psaux"
     Option "Emulate3Buttons" "no"
     Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
     Identifier "Keyboard0"
     Driver "kbd"
EndSection

Section "Monitor"
     Identifier "Monitor0"
     VendorName "Dell, Inc."
     ModelName "DELL E207WFP"
     HorizSync 30.0 - 83.0
     VertRefresh 56.0 - 75.0
     Option "DPMS"
EndSection

Section "Device"
     Identifier "Device0"
     Driver "nvidia"
     VendorName "NVIDIA Corporation"
     BoardName "Geforce GTX 970"
     BusID "PCI:1:0:0"
EndSection 

Section "Screen"
     Identifier "Screen0"
     Device "Device0"
     Monitor "Monitor0"
     DefaultDepth 24
     Option "Stereo" "0"
     Option "nvidiaXineramaInfoOrder" "DFP-0"
     Option "metamodes" "GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.DVI-I-1: nvidia-auto-select +0+0, 
                         GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.DVI-D-0: nvidia-auto-select +1680+0, 
                         GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.DVI-I-1: nvidia-auto-select +3360+0, 
                         GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.DVI-D-0: nvidia-auto-select +5040+0"

                        #GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.DP-1: nvidia-auto-select +1680+1050,
                        #GPU-a0bd4a65-1c2b-f765-eeb2-db96b3f4b25a.GPU-0.HDMI-0: nvidia-auto-select +0+1050,

                        #GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.HDMI-0: nvidia-auto-select +3360+1050,
                        #GPU-a85ce4bc-1e9b-6275-2aee-0d1ed8bd7ce2.GPU-1.DP-1: nvidia-auto-select +5040+1050"
     Option "MultiGPU" "Off"
     Option "SLI" "on"
     Option "BaseMosaic" "on"
     SubSection "Display"
         Depth 24
     EndSubSection
EndSection