X11

為什麼我的 NVIDIA 驅動程序已載入但 X.org 未檢測到?

  • July 18, 2021

我使用的是安裝了 X.org 的 Debian 10 系統,LightDM 作為顯示管理器,GNOME 作為桌面環境。當我啟動 LightDM 時,只有一個物理顯示器啟動。我有兩台顯示器,一台內置,由我的集成英特爾顯卡驅動,一台外置 HDMI,由我的獨立英偉達顯卡驅動。我已經使用 bumblebee/primus 設置了 NVIDIA Optimus,因此我可以使用我的集成英特爾顯卡來驅動顯示器,同時在我的獨立卡上執行應用程序。當我啟動 LightDM 時,X 伺服器只使用內部螢幕,而我的顯示器仍處於待機狀態。即使不推薦使用 Xorg 配置文件,我也需要使用它,否則 Xorg 將無法檢測到我的外部顯示器。

/etc/X11/xorg.conf:

Section "ServerLayout"
   Identifier     "X.org Configured"
   Screen      0  "Screen0" 0 0
   Screen      1  "Screen1" RightOf "Screen0"
   InputDevice    "Mouse0" "CorePointer"
   InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
   ModulePath   "/usr/lib/xorg/modules"
   FontPath     "/usr/share/fonts/X11/misc"
   FontPath     "/usr/share/fonts/X11/cyrillic"
   FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
   FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
   FontPath     "/usr/share/fonts/X11/Type1"
   FontPath     "/usr/share/fonts/X11/100dpi"
   FontPath     "/usr/share/fonts/X11/75dpi"
   FontPath     "built-ins"
EndSection

Section "Module"
   Load  "glx"
EndSection

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

Section "InputDevice"
   Identifier  "Mouse0"
   Driver      "mouse"
   Option      "Protocol" "auto"
   Option      "Device" "/dev/input/mice"
   Option      "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
   Identifier   "Monitor0"
   VendorName   "Monitor Vendor"
   ModelName    "Monitor Model"
EndSection

Section "Monitor"
   Identifier   "Monitor1"
   VendorName   "Monitor Vendor"
   ModelName    "Monitor Model"
EndSection

Section "Device"
       ### Available Driver options are:-
       ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
       ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
       ### <percent>: "<f>%"
       ### [arg]: arg optional
       #Option     "Accel"                 # [<bool>]
       #Option     "AccelMethod"           # <str>
       #Option     "Backlight"             # <str>
       #Option     "CustomEDID"            # <str>
       #Option     "DRI"                   # <str>
       #Option     "Present"               # [<bool>]
       #Option     "ColorKey"              # <i>
       #Option     "VideoKey"              # <i>
       #Option     "Tiling"                # [<bool>]
       #Option     "LinearFramebuffer"     # [<bool>]
       #Option     "HWRotation"            # [<bool>]
       #Option     "VSync"                 # [<bool>]
       #Option     "PageFlip"              # [<bool>]
       #Option     "SwapbuffersWait"       # [<bool>]
       #Option     "TripleBuffer"          # [<bool>]
       #Option     "XvPreferOverlay"       # [<bool>]
       #Option     "HotPlug"               # [<bool>]
       #Option     "ReprobeOutputs"        # [<bool>]
       #Option     "XvMC"                  # [<bool>]
       #Option     "ZaphodHeads"           # <str>
       #Option     "VirtualHeads"          # <i>
       #Option     "TearFree"              # [<bool>]
       #Option     "PerCrtcPixmaps"        # [<bool>]
       #Option     "FallbackDebug"         # [<bool>]
       #Option     "DebugFlushBatches"     # [<bool>]
       #Option     "DebugFlushCaches"      # [<bool>]
       #Option     "DebugWait"             # [<bool>]
       #Option     "BufferCache"           # [<bool>]
   Identifier  "Card0"
   Driver      "intel"
   BusID       "PCI:0:2:0"
EndSection

Section "Device"
       ### Available Driver options are:-
       ### Values: <i>: integer, <f>: float, <bool>: "True"/"False"ss,
       ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
       ### <percent>: "<f>%"
       ### [arg]: arg optional
       #Option     "SWcursor"              # [<bool>]
       #Option     "HWcursor"              # [<bool>]
       #Option     "NoAccel"               # [<bool>]
       #Option     "ShadowFB"              # [<bool>]
       #Option     "VideoKey"              # <i>
       #Option     "WrappedFB"             # [<bool>]
       #Option     "GLXVBlank"             # [<bool>]
       #Option     "ZaphodHeads"           # <str>
       #Option     "PageFlip"              # [<bool>]
       #Option     "SwapLimit"             # <i>
       #Option     "AsyncUTSDFS"           # [<bool>]
       #Option     "AccelMethod"           # <str>
       #Option     "DRI"                   # <i>
   Identifier  "Card1"
   Driver      "nvidia"
   BusID       "PCI:1:0:0"
EndSection

Section "Screen"
   Identifier "Screen0"
   Device     "Card0"
   Monitor    "Monitor0"
   SubSection "Display"
       Viewport   0 0
       Depth     1
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     4
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     8
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     15
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     16
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     24
   EndSubSection
EndSection

Section "Screen"
   Identifier "Screen1"
   Device     "Card1"
   Monitor    "Monitor1"
   SubSection "Display"
       Viewport   0 0
       Depth     1
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     4
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     8
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     15
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     16
   EndSubSection
   SubSection "Display"
       Viewport   0 0
       Depth     24
   EndSubSection
EndSection

lspci | grep NVIDIA 顯示我的圖形被檢測到:

01:00.0 VGA compatible controller: NVIDIA Corporation Device 1f99 (rev a1)

lsmod | grep nvidia 顯示已載入 nvidia 驅動程序:

nvidia_modeset       1232896  1
nvidia              34164736  18 nvidia_modeset

我的 LightDM 配置文件沒有設置 xserver-config 欄位,因此它將使用 /etc/X11/xorg.conf

我無法發布整個 X.org 日誌,因為它的字元太多。最值得注意的三行是:

[  9581.561] (II) LoadModule: "nvidia"
[  9581.562] (WW) Warning, couldn't open module nvidia
[  9581.562] (EE) Failed to load module "nvidia" (module does not exist, 0)

我有兩個問題:

  1. 為什麼我的顯卡被 lspci 檢測到,驅動被 lsmod 檢測到,但是 Xorg 說驅動不存在?
  2. 我怎樣才能讓 X.org 檢測到驅動程序?

PS:nouveau 驅動程序沒有載入,也沒有在 Xorg 配置中提及,所以它們不應該成為問題。

我升級到 Debian Rolling Release (unstable/sid),它現在可以工作了。我真的不知道問題出在哪裡,我認為是關於大黃蜂/primus 的問題。升級後,我現在擁有 Xorg 1.20.11,因此我可以原生使用 NVIDIA Optimus。一個驅動程序重新安裝+稍後清除,效果很好。

引用自:https://unix.stackexchange.com/questions/657842