9
9

More than 3 years have passed since last update.

複数GPU環境でnvidia-xconfigでxorg.confを作ったら画面表示するGPUカードが変わってしまったので直した

Last updated at Posted at 2020-03-06

複数GPU使用時にnvidia-xconfigで/etc/X11/xorg.confを作成したら、GPUの順番がおかしくなってしまったので、それを直したときのメモ。

version
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
$ uname -a
Linux 230-dlbox 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ dpkg -S /usr/bin/nvidia-xconfig
nvidia-utils-440: /usr/bin/nvidia-xconfig
$ dpkg -l | grep nvidia-utils
ii  nvidia-utils-440                           440.33.01-0ubuntu1                               amd64        NVIDIA driver support binaries

xorg.confを作る

作成する
sudo cp /etc/X11/xorg.conf{,.mybackup}
sudo nvidia-xconfig -a

これで再起動して問題なくXが起動したらOK。

症状

でも4枚GPUを使用していて、0番GPUにHDMIケーブルを挿していてBIOSからXまで問題なく表示されていたのに、nvidia-xconfig後は「BIOSとubuntu起動コンソールは0番GPU」「Xは3番GPUに挿し直さないと表示されない」問題が生じた。

調査

  • nvidia-setting(XのGUI版)で表示すると、HDMIを挿している3番GPUがなぜか0番と表示されていた。(PCI:10.0.0のカード)
  • でもlspciとnvida-smiでは順番は問題なし
確認
$ lspci |grep NVI | grep VGA
05:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
06:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
09:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
0a:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
$ nvidia-smi -q | grep -A 1 "^GPU"
GPU 00000000:05:00.0
    Product Name                    : GeForce GTX 1080 Ti
--
GPU 00000000:06:00.0
    Product Name                    : GeForce GTX 1080 Ti
--
GPU 00000000:09:00.0
    Product Name                    : GeForce GTX 1080 Ti
--
GPU 00000000:0A:00.0
    Product Name                    : GeForce GTX 1080 Ti

原因

nvidia-xconfigがGPUの順番を変えてしまったらしく、PCI:10.0.0がDevice0にされてしまっていた。

/etc/X11/xorg.conf
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:10:0:0"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:9:0:0"
EndSection

Section "Device"
    Identifier     "Device2"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:6:0:0"
EndSection

Section "Device"
    Identifier     "Device3"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:5:0:0"
EndSection

そこで以下のように手動修正

/etc/X11/xorg.conf
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:5:0:0"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:6:0:0"
EndSection

Section "Device"
    Identifier     "Device2"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:9:0:0"
EndSection

Section "Device"
    Identifier     "Device3"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:10:0:0"
EndSection

無事にこれでBIOSもXも0番GPU(PCI:5:0:0)で表示されるようになった。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9