PCI 直通后更改 Xorg/GDM 的默认 GPU 设备?

PCI 直通后更改 Xorg/GDM 的默认 GPU 设备?

Intel Corporation HD Graphics 510设备应用于 Ubuntu 主机系统。

NVIDIA Corporation GP107设备已保留供 KVM 使用。

Ubuntu 主机系统无法正常Intel Corporation HD Graphics 510连接到 X 服务器。我们可以解决这个问题吗?

sudo systemctl start gdm命令会导致TTY持续闪烁,难以使用。

sudo cat /etc/default/grub | grep CMDLINE

GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity nouveau.runpm=0"
GRUB_CMDLINE_LINUX="rd.modules-load=vfio-pci intel_iommu=on"

猫/etc/modprobe.d/local.conf

options vfio-pci ids=10de:1c81,10de:0fb9
options vfio-pci disable_vga=1

sudo 更新 grub

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-32-generic
Found initrd image: /boot/initrd.img-4.15.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-30-generic
Found initrd image: /boot/initrd.img-4.15.0-30-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

sudo 更新-initramfs -u

update-initramfs: Generating /boot/initrd.img-4.15.0-32-generic

systemctl 重启

cat ~/.local/share/xorg/Xorg.0.log

[   876.205] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_3253
[   876.206] (II) xfree86: Adding drm device (/dev/dri/card0)
[   876.208] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 11 paused 0
[   876.214] (--) PCI: (0:0:2:0) 8086:1902:1462:7995 rev 6, Mem @ 0xdd000000/16777216, 0xb0000000/268435456, I/O @ 0x0000f000/64
[   876.214] (--) PCI:*(0:1:0:0) 10de:1c81:1462:8c97 rev 161, Mem @ 0xde000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/131072
[   876.214] (II) LoadModule: "glx"
[   876.214] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so

lspci-tvnnk

-[0000:00]-+-00.0  Intel Corporation Skylake Host Bridge/DRAM Registers [8086:190f]
        +-01.0-[01]--+-00.0  NVIDIA Corporation GP107 [GeForce GTX 1050] [10de:1c81]
        |            \-00.1  NVIDIA Corporation GP107GL High Definition Audio Controller [10de:0fb9]
        +-02.0  Intel Corporation HD Graphics 510 [8086:1902]
        +-08.0  Intel Corporation Skylake Gaussian Mixture Model [8086:1911]
        +-14.0  Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller [8086:a12f]
        +-14.2  Intel Corporation Sunrise Point-H Thermal subsystem [8086:a131]
        +-16.0  Intel Corporation Sunrise Point-H CSME HECI #1 [8086:a13a]
        +-17.0  Intel Corporation Sunrise Point-H SATA controller [AHCI mode] [8086:a102]
        +-1d.0-[02]----00.0  Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168]
        +-1f.0  Intel Corporation Sunrise Point-H LPC Controller [8086:a143]
        +-1f.2  Intel Corporation Sunrise Point-H PMC [8086:a121]
        +-1f.3  Intel Corporation Sunrise Point-H HD Audio [8086:a170]
        \-1f.4  Intel Corporation Sunrise Point-H SMBus [8086:a123]

lspci-nnks 01:00

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP107 [GeForce GTX 1050] [10de:1c81] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] GP107 [GeForce GTX 1050] [1462:8c97]
    Kernel driver in use: vfio-pci
    Kernel modules: nvidiafb, nouveau
01:00.1 Audio device [0403]: NVIDIA Corporation GP107GL High Definition Audio Controller [10de:0fb9] (rev a1)
    Subsystem: Micro-Star International Co., Ltd. [MSI] GP107GL High Definition Audio Controller [1462:8c97]
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel

lspci-nnks 00:02

00:02.0 Display controller [0380]: Intel Corporation HD Graphics 510 [8086:1902] (rev 06)
    Subsystem: Micro-Star International Co., Ltd. [MSI] HD Graphics 510 [1462:7995]
    Kernel driver in use: i915
    Kernel modules: i915

gpu-manager.log:

log_file: /var/log/gpu-manager.log
last_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
new_boot_file: /var/lib/ubuntu-drivers-common/last_gfx_boot
can't access /run/u-d-c-nvidia-was-loaded file
can't access /opt/amdgpu-pro/bin/amdgpu-pro-px
Looking for nvidia modules in /lib/modules/4.15.0-32-generic/updates/dkms
Looking for amdgpu modules in /lib/modules/4.15.0-32-generic/updates/dkms
Is nvidia loaded? no
Was nvidia unloaded? no
Is nvidia blacklisted? no
Is intel loaded? yes
Is radeon loaded? no
Is radeon blacklisted? no
Is amdgpu loaded? no
Is amdgpu blacklisted? no
Is amdgpu versioned? no
Is amdgpu pro stack? no
Is nouveau loaded? no
Is nouveau blacklisted? yes
Is nvidia kernel module available? no
Is amdgpu kernel module available? no
Vendor/Device Id: 8086:1902
BusID "PCI:0@0:2:0"
Is boot vga? no
Vendor/Device Id: 10de:1c81
BusID "PCI:1@0:0:0"
Is boot vga? yes
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Skipping "/dev/dri/card0", driven by "i915"
Found "/dev/dri/card0", driven by "i915"
output 0:
        card0-HDMI-A-1
Number of connected outputs for /dev/dri/card0: 1
Does it require offloading? yes
last cards number = 2
Has amd? no
Has intel? yes
Has nvidia? yes
How many cards? 2
Has the system changed? No
Unsupported discrete card vendor: 8086
Nothing to do

Xorg.0.日志:

$ cat ~/.local/share/xorg/Xorg.0.log
[  2684.239]
X.Org X Server 1.19.6
Release Date: 2017-12-20
[  2684.244] X Protocol Version 11, Revision 0
[  2684.246] Build Operating System: Linux 4.4.0-119-generic x86_64 Ubuntu
[  2684.247] Current Operating System: Linux ab350n2 4.15.0-32-generic #35-Ubuntu SMP Fri Aug 10 17:58:07 UTC 2018 x86_64
[  2684.247] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-32-generic root=UUID=87ad8dee-9975-11e8-a30b-309c230abb92 ro rd.modules-load=vfio-pci intel_iommu=on maybe-ubiquity
[  2684.251] Build Date: 13 April 2018  08:07:36PM
[  2684.253] xorg-server 2:1.19.6-1ubuntu4 (For technical support please see http://www.ubuntu.com/support)
[  2684.254] Current version of pixman: 0.34.0
[  2684.258]    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
[  2684.258] Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  2684.265] (==) Log file: "/home/$USER/.local/share/xorg/Xorg.0.log", Time: Tue Aug 21 11:35:44 2018
[  2684.267] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  2684.267] (==) No Layout section.  Using the first Screen section.
[  2684.267] (==) No screen section available. Using defaults.
[  2684.267] (**) |-->Screen "Default Screen Section" (0)
[  2684.267] (**) |   |-->Monitor "<default monitor>"
[  2684.267] (==) No monitor specified for screen "Default Screen Section".
    Using a default monitor configuration.
[  2684.267] (==) Automatically adding devices
[  2684.267] (==) Automatically enabling devices
[  2684.267] (==) Automatically adding GPU devices
[  2684.267] (==) Automatically binding GPU devices
[  2684.267] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  2684.267] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
[  2684.267]    Entry deleted from font path.
[  2684.267] (==) FontPath set to:
    /usr/share/fonts/X11/misc,
    /usr/share/fonts/X11/Type1,
    built-ins
[  2684.267] (==) ModulePath set to "/usr/lib/xorg/modules"
[  2684.267] (II) The server relies on udev to provide the list of input devices.
    If no devices become available, reconfigure udev or disable AutoAddDevices.
[  2684.267] (II) Loader magic: 0x564f402c8020
[  2684.267] (II) Module ABI versions:
[  2684.267]    X.Org ANSI C Emulation: 0.4
[  2684.267]    X.Org Video Driver: 23.0
[  2684.267]    X.Org XInput driver : 24.1
[  2684.267]    X.Org Server Extension : 10.0
[  2684.268] (++) using VT number 5

[  2684.269] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_3253
[  2684.270] (II) xfree86: Adding drm device (/dev/dri/card0)
[  2684.270] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 11 paused 0
[  2684.271] (--) PCI: (0:0:2:0) 8086:1902:1462:7995 rev 6, Mem @ 0xdd000000/16777216, 0xb0000000/268435456, I/O @ 0x0000f000/64
[  2684.271] (--) PCI:*(0:1:0:0) 10de:1c81:1462:8c97 rev 161, Mem @ 0xde000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/131072
[  2684.271] (II) LoadModule: "glx"
[  2684.272] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[  2684.272] (II) Module glx: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.6, module version = 1.0.0
[  2684.272]    ABI class: X.Org Server Extension, version 10.0
[  2684.272] (==) Matched nouveau as autoconfigured driver 0
[  2684.272] (==) Matched modesetting as autoconfigured driver 1
[  2684.272] (==) Matched fbdev as autoconfigured driver 2
[  2684.272] (==) Matched vesa as autoconfigured driver 3
[  2684.272] (==) Assigned the driver to the xf86ConfigLayout
[  2684.272] (II) LoadModule: "nouveau"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/nouveau_drv.so
[  2684.272] (II) Module nouveau: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.3, module version = 1.0.15
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "modesetting"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
[  2684.272] (II) Module modesetting: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.6, module version = 1.19.6
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "fbdev"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[  2684.272] (II) Module fbdev: vendor="X.Org Foundation"
[  2684.272]    compiled for 1.19.3, module version = 0.4.4
[  2684.272]    Module class: X.Org Video Driver
[  2684.272]    ABI class: X.Org Video Driver, version 23.0
[  2684.272] (II) LoadModule: "vesa"
[  2684.272] (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
[  2684.273] (II) Module vesa: vendor="X.Org Foundation"
[  2684.273]    compiled for 1.19.3, module version = 2.3.4
[  2684.273]    Module class: X.Org Video Driver
[  2684.273]    ABI class: X.Org Video Driver, version 23.0
[  2684.273] (II) NOUVEAU driver Date:   Fri Apr 21 14:41:17 2017 -0400
[  2684.273] (II) NOUVEAU driver for NVIDIA chipset families :
[  2684.273]    RIVA TNT        (NV04)
[  2684.273]    RIVA TNT2       (NV05)
[  2684.273]    GeForce 256     (NV10)
[  2684.273]    GeForce 2       (NV11, NV15)
[  2684.273]    GeForce 4MX     (NV17, NV18)
[  2684.273]    GeForce 3       (NV20)
[  2684.273]    GeForce 4Ti     (NV25, NV28)
[  2684.273]    GeForce FX      (NV3x)
[  2684.273]    GeForce 6       (NV4x)
[  2684.273]    GeForce 7       (G7x)
[  2684.273]    GeForce 8       (G8x)
[  2684.273]    GeForce GTX 200 (NVA0)
[  2684.273]    GeForce GTX 400 (NVC0)
[  2684.273] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  2684.273] (II) FBDEV: driver for framebuffer: fbdev
[  2684.273] (II) VESA: driver for VESA chipsets: vesa
[  2684.273] xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
[  2684.391] (EE) [drm] Failed to open DRM device for pci:0000:01:00.0: -19
[  2684.391] (WW) Falling back to old probe method for modesetting
[  2684.391] (II) modeset(1): using default device
[  2684.391] (II) Loading sub module "fbdevhw"
[  2684.391] (II) LoadModule: "fbdevhw"
[  2684.391] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  2684.391] (II) Module fbdevhw: vendor="X.Org Foundation"
[  2684.391]    compiled for 1.19.6, module version = 0.0.2
[  2684.392]    ABI class: X.Org Video Driver, version 23.0
[  2684.392] (EE) open /dev/fb0: Permission denied
[  2684.392] (WW) Falling back to old probe method for fbdev
[  2684.392] (II) Loading sub module "fbdevhw"
[  2684.392] (II) LoadModule: "fbdevhw"
[  2684.392] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  2684.392] (II) Module fbdevhw: vendor="X.Org Foundation"
[  2684.392]    compiled for 1.19.6, module version = 0.0.2
[  2684.392]    ABI class: X.Org Video Driver, version 23.0
[  2684.392] (EE) open /dev/fb0: Permission denied
[  2684.392] vesa: Ignoring device with a bound kernel driver
[  2684.392] (WW) Falling back to old probe method for vesa
[  2684.392] (II) modeset(G0): using drv /dev/dri/card0
[  2684.392] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[  2684.392] (EE) Screen 0 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "modesetting"
[  2684.392] (EE) Screen 1 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "fbdev"
[  2684.392] (II) UnloadSubModule: "fbdevhw"
[  2684.392] (EE) Screen 1 deleted because of no matching config section.
[  2684.392] (II) UnloadModule: "vesa"
[  2684.392] (EE)
Fatal server error:
[  2684.392] (EE) Cannot run in framebuffer mode. Please specify busIDs        for all framebuffer devices
[  2684.392] (EE)
[  2684.392] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
for help.
[  2684.392] (EE) Please also check the log file at "/home/$USER/.local/share/xorg/Xorg.0.log" for additional information.
[  2684.392] (EE)
[  2684.423] (EE) Server terminated with error (1). Closing log file.

答案1

嗯,看起来 Xorg 正在尝试使用 NVIDIA 卡。你试过了吗指定 Xorg 应该使用哪个 GPU

启用 vfio_pci 后 X 无法启动

这与主机 GPU 被检测为辅助 GPU 有关,这会导致 X 在尝试为客户 GPU 加载驱动程序时失败/崩溃。为了避免这种情况,需要一个指定主机 GPU 的 BusID 的 Xorg 配置文件。可以从 lspci 或 Xorg 日志中获取正确的 BusID。来源 →

/etc/X11/xorg.conf.d/10-intel.conf

Section "Device"
        Identifier "Intel GPU"
        Driver "modesetting"
        BusID  "PCI:0:2:0"
EndSection

如果xorg.conf.d尚不存在,则只需创建它。

此后,Xorg 不应再尝试使用 NVIDIA 显卡。Arch Wiki 页面列出了其他问题,随着您进一步了解,您可能会发现这些问题很有趣。

答案2

我在台式电脑上安装第二个 NVIDIA GPU 后遇到了相关问题。尝试启动时,日志显示 gdm(Gnome Display Manager 3)已启动,但我只看到左上角有一个闪烁的光标。

正如 @Daniel B 在接受的答案中提到的那样,修复与 Xorg 配置文件有关。我能够使用 NVIDIA 实用程序生成正确的配置文件。

  1. 启动到运行级别 3(允许在图形启动失败时获取终端):e在引导加载程序屏幕上按下,然后将其添加3到行尾linuxefi并使用 开始引导ctrl + x
  2. 使用您的标准用户名和密码登录。
  3. 备份任何现有的 Xorg 配置:sudo cp -r /etc/X11/xorg.conf.d /etc/X11/xorg.conf.d.bak
  4. 使用 NVIDIA 的工具创建新的 Xorg 配置:sudo nvidia-xconfig -a
  5. 新的配置文件可能没有放在正确的位置。如果/etc/X11/xorg.conf.d/10-nvidia.conf存在或类似情况,请确保已备份,然后将新的配置文件复制过来:(sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-nvidia.conf 我必须在 Fedora 29 上执行此操作)。
  6. 重启:sudo reboot

请注意,上面的路径对应于 Fedora 29,可能需要根据您的发行版存储这些配置文件的位置进行调整。

相关内容