UbuntuでdGPU/iGPUのデュアルモニタ設定
1枚のNVIDIA GPUと、CPUの統合グラフィクス(iGPU)の2つのGPUにそれぞれモニタを接続してデュアルディスプレイ環境をセットアップする手順。
環境
参考
手順
古いNVIDIAドライバのアンインストールと新しいNVIDIAドライバのインストール
Ubuntu18.04 で実行したもの。 本節については次のページを参考にした:
古いドライバ削除
sudo apt-get --purge remove nvidia-* sudo apt-get --purge remove cuda-* sudo apt-get --purge remove libnvidia-*
なお自分の環境ではCUDA関係はインストールしていなかったので2行目は意味がなかった。
Proprietary GPU Drivers PPA の登録
sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update
NVIDIAドライバインストール
apt-cache search nvidia
で`nvidia`を名前に含むパッケージ一覧が検索できるので、ついている数値の一番大きい(一番最新の)ものをインストールする。 今回は410だった。
sudo apt-get install nvidia-driver-410
従来は nvidia-nnn という名前だったが最近のものは nvidia-driver-nnn という命名になっているようだ。
再起動して次のコマンドでGPUが認識されていることを確認:
nvidia-smi
/etc/X11/xorg.conf 作成
PCI BusID を調べる
`lspci`コマンドで調べられる:
lspci | grep NVIDIA | grep -v Audio | sed -e "s/^0*\(.\+\):0*\(.\+\)\.\(.\)\ .*$/PCI:\1:\2:\3/"
あるいは次のコマンドでも可:
nvidia-xconfig --query-gpu-info
自分の環境では`PCI:1:0:0`であった。
/etc/X11/xorg.conf 記述
/etc/X11/xorg.conf ファイルを新規作成し、次をペーストする[3]:
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "<BusID for NVIDIA device here>"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
# Uncomment this line if your computer has no display devices connected to
# the NVIDIA GPU. Leave it commented if you have display devices
# connected to the NVIDIA GPU that you would like to use.
#Option "UseDisplayDevice" "none"
EndSection
Section "Device"
Identifier "intel"
Driver "modesetting"
EndSection
Section "Screen"
Identifier "intel"
Device "intel"
EndSection
上記のうち、
BusID "<BusID for NVIDIA device here>"
の箇所に調べておいたBusIDを記載する。つまり次のように書き換える:
BusID "PCI:1:0:0"
~/.xsessionrc 作成
今回`~/.xsessionrc`は存在していなかったので新規作成した。 次のコマンドを追記する:
xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto
`NVIDIA-0`というのは、おそらく次のコマンドで表示されるnameだろう:
xrandr --listproviders
あとはXを再起動し、Ubuntuのシステム設定の画面でディスプレイ設定を行えば完了。
手順(390の頃の古い手順; 2018/01ごろ記述)
古いNVIDIAドライバのアンインストールと新しいNVIDIAドライバのインストール
本節については次のページを参考にした:
古いドライバ削除
sudo apt-get --purge remove nvidia-* sudo apt-get --purge remove cuda-*
なお自分の環境ではCUDA関係はインストールしていなかったので2行目は意味がなかった。
Proprietary GPU Drivers PPA の登録
sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update
NVIDIAドライバインストール
apt-cache search nvidia
で`nvidia`を名前に含むパッケージ一覧が検索できるので、`nvidia-nnn`の`nnn`が一番大きいもの(つまり最新のドライバ)をインストールする。 今回は390だった。
sudo apt-get install nvidia-390
再起動して次のコマンドでGPUが認識されていることを確認:
nvidia-smi
`/etc/X11/xorg.conf`作成
PCI BusID を調べる
`lspci`コマンドで調べられる:
lspci | grep NVIDIA | grep -v Audio | sed -e "s/^0*\(.\+\):0*\(.\+\)\.\(.\)\ .*$/PCI:\1:\2:\3/"
あるいは次のコマンドでも可:
nvidia-xconfig --query-gpu-info
自分の環境では`PCI:1:0:0`であった。
/etc/X11/xorg.conf 記述
`/etc/X11/xorg.conf`ファイルを新規作成し、次をペーストする[4]:
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "<BusID for NVIDIA device here>"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
# Uncomment this line if your computer has no display devices connected to
# the NVIDIA GPU. Leave it commented if you have display devices
# connected to the NVIDIA GPU that you would like to use.
#Option "UseDisplayDevice" "none"
EndSection
Section "Device"
Identifier "intel"
Driver "modesetting"
EndSection
Section "Screen"
Identifier "intel"
Device "intel"
EndSection
上記のうち、
BusID "<BusID for NVIDIA device here>"
の箇所に調べておいたBusIDを記載する。つまり次のように書き換える:
BusID "PCI:1:0:0"
~/.xsessionrc 作成
今回`~/.xsessionrc`は存在していなかったので新規作成した。 次のコマンドを追記する:
xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto
`NVIDIA-0`というのは、おそらく次のコマンドで表示されるnameだろう:
xrandr --listproviders
あとはXを再起動し、Ubuntuのシステム設定の画面でディスプレイ設定を行えば完了。