NVIDIAのGPUを搭載したグラフィックボードが人気です。2016年はVR・
NVIDIA製GPUのドライバーについて
Ubuntuで一般的に使われているNVIDIA製GPU向けドライバーには、
- コミュニティ製のFLOSSなドライバー
(nouveau) - NVIDIA製のプロプライエタリなドライバー
Ubuntuをインストールした直後であれば、
$ dmesg | grep -i nouveau [ 0.811191] nouveau 0000:01:00.0: enabling device (0000 -> 0003) [ 0.811682] nouveau 0000:01:00.0: unknown chipset (137000a1) [ 0.813001] nouveau: probe of 0000:01:00.0 failed with error -12
nouveauは今のところグラフィックドライバーとしての開発をメインターゲットにしているため、
さてそのNVIDIA製ドライバーですが、
- Ubuntuの公式リポジトリからパッケージとしてインストールする方法
- Graphics Drivers TeamのPPAからパッケージとしてインストールする方法
- NVIDIAのサイトからダウンロードしてインストールする方法
まず最初にUbuntuでは公式リポジトリに複数のバージョンのNVIDIA製ドライバーをパッケージとして提供しています。
$ apt search "^nvidia-[0-9]{3}$" ソート中... 完了 全文検索... 完了 nvidia-304/xenial-updates,xenial-security 304.132-0ubuntu0.16.04.2 amd64 NVIDIA legacy binary driver - version 304.132 nvidia-331/xenial-updates,xenial-security 340.98-0ubuntu0.16.04.1 amd64 Transitional package for nvidia-331 nvidia-340/xenial-updates,xenial-security 340.98-0ubuntu0.16.04.1 amd64 NVIDIA binary driver - version 340.98 nvidia-346/xenial 352.63-0ubuntu3 amd64 Transitional package for nvidia-346 nvidia-352/xenial 361.42-0ubuntu2 amd64 Transitional package for nvidia-361 nvidia-361/xenial-updates,xenial-security 367.57-0ubuntu0.16.04.1 amd64 Transitional package for nvidia-367 nvidia-367/xenial-updates,xenial-security 367.57-0ubuntu0.16.04.1 amd64 NVIDIA binary driver - version 367.57
ここで
最新のグラフィックチップでなければ、
Graphics Drivers TeamのPPAにはより新しいバージョンのドライバーパッケージが用意されています。これらは主に公式リポジトリに取り込むためのテスト目的のパッケージであるため、
いずれのパッケージもNVIDIAのサイトで公開されているドライバーが元になっています。つまりNVIDIAのサイトからドライバーをダウンロードする方法であれば、
もしGPGPUとして使うことのみが目的でありGUIが必要ない場合であれば、
プロプライエタリなドライバーのインストール方法
ここからは実際のインストール手順を解説します。まず最初にNVIDIA製のドライバーをインストールする際の注意点です。
- セキュアブートは無効化しておく
- デクストップ環境が立ち上がらなくなった時のリカバリー手段を用意しておく
- GPGPU目的ならグラフィックの出力先をNVIDIAのGPU以外にしておく
第444回でも紹介したようにセキュアブートは特定の鍵で署名されたブートローダーやカーネルのみを起動する仕組みです。Ubuntuの場合、mokutil
コマンドで登録する方法もあります。ただし手順や鍵の管理が若干煩雑ですので、
ちなみに公式パッケージもしくはPPAのNVIDA製ドライバーをインストールする場合は、update-secureboot-policy
コマンドを実行し、


この画面の指示に従えば次回起動時にパスワード入力画面があらわれ、/boot/
が呼び出されます。このUEFIアプリケーションが、
2つ目の注意点である
別の手段としてあらかじめSSHサーバー
最後の注意点である
ここまで注意しておけば、
Graphics Drivers TeamのPPAの導入
使用しているGPUが新しすぎて公式リポジトリのパッケージではサポートしておらず、
(PPAを使う場合のみ実行する) $ sudo add-apt-repository ppa:graphics-drivers/ppa Fresh drivers from upstream, currently shipping Nvidia. ## Current Status Current official release: `nvidia-370` (370.28) Current long-lived branch release: `nvidia-367` (367.57) (中略) 詳しい情報: https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa [ENTER] を押すと続行します。ctrl-c で追加をキャンセルできます gpg: 鍵リング「/tmp/tmp012277dn/secring.gpg」ができました gpg: 鍵リング「/tmp/tmp012277dn/pubring.gpg」ができました gpg: 鍵1118213Cをhkpからサーバkeyserver.ubuntu.comに要求 gpg: /tmp/tmp012277dn/trustdb.gpg: 信用データベースができました gpg: 鍵1118213C: 公開鍵"Launchpad PPA for Graphics Drivers Team"をインポートしました gpg: 処理数の合計: 1 gpg: インポート: 1 (RSA: 1) OK $ sudo apt update
デスクトップ環境からパッケージをインストールする場合
デスクトップ環境が動いている状況で、

少し待てば、
インストールしたいドライバーを選択して
またデスクトップ関連の設定は、nvidia-settings
」~/.nvidia-settings-rc
」/etc/
」
nvidia-settings
による設定ダイアログ
パッケージとしてインストールした場合は、/usr/
」nvidia-375
」
デスクトップ環境以外からパッケージをインストールする場合
Ubuntuサーバー上でNVIDIAのドライバーをパッケージとしてインストールする場合は、
$ sudo apt install nvidia-375
最後のnvidia-375
」ubuntu-drivers
コマンドを利用すると、
$ sudo ubuntu-drivers devices == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 == vendor : NVIDIA Corporation modalias : pci:v000010DEd00001C82sv00001458sd00003729bc03sc00i00 driver : nvidia-375 - third-party free recommended driver : xserver-xorg-video-nouveau - distro free builtin == cpu-microcode.py == driver : intel-microcode - distro non-free
インストールが完了したら、/etc/
や/etc/
にblacklist nouveau
」
$ lsmod | grep nvidia nvidia_uvm 749568 0 nvidia_drm 53248 2 nvidia_modeset 790528 3 nvidia_drm nvidia 11943936 42 nvidia_modeset,nvidia_uvm drm_kms_helper 155648 2 i915_bpo,nvidia_drm drm 364544 6 i915_bpo,drm_kms_helper,nvidia_drm
またnouveauドライバーだと
$ dmesg | grep -i nvidia [ 0.882221] nvidia: module license 'NVIDIA' taints kernel. [ 0.886132] nvidia: module verification failed: signature and/or required key missing - tainting kernel [ 0.890079] nvidia 0000:01:00.0: enabling device (0000 -> 0003) [ 0.891493] nvidia-nvlink: Nvlink Core is being initialized, major device number 244 [ 0.892145] NVRM: loading NVIDIA UNIX x86_64 Kernel Module 375.26 Thu Dec 8 18:36:43 PST 2016 (using threaded interrupts) [ 0.894858] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms 375.26 Thu Dec 8 18:04:14 PST 2016 [ 0.897217] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver [ 4.209092] nvidia-uvm: Loaded the UVM driver in 8 mode, major device number 241 [ 4.868521] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input20 [ 4.868572] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input21 [ 4.868622] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input22 [ 16.823727] nvidia-modeset: Allocated GPU:0 (GPU-6fae1717-190c-1843-3fb8-c3d6cd190739) @ PCI:0000:01:00.0
前述したようにパッケージ版のNVIDIA製ドライバーはデスクトップ環境のパッケージ一式に依存しています。このためUbuntuサーバー上でインストールしようとすると、
$ sudo apt install nvidia-375 以下のパッケージが新たにインストールされます: (とてもたくさんのパッケージリスト) アップグレード: 0 個、新規インストール: 601 個、削除: 0 個、保留: 0 個。 276 MB のアーカイブを取得する必要があります。 この操作後に追加で 1,261 MB のディスク容量が消費されます。 続行しますか? [Y/n]
推奨パッケージをインストールしない--no-install-recommends
」
NVIDIAのインストールスクリプトを利用する場合
インストールスクリプトはNVIDIAのサイトで利用OSなど必要な情報を入力するか、.run
」
ダウンロードしたファイルは、--help
」
$ chmod 755 NVIDIA-Linux-x86_64-375.26.run $ ./NVIDIA-Linux-x86_64-375.26.run --help ./NVIDIA-Linux-x86_64-375.26.run [options] This program will install the NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26 by unpacking the embedded tarball and executing the ./nvidia-installer installation utility. Below are the most common options; for a complete list use '--advanced-options'. --info Print embedded info (title, default target directory) and exit. --check Check integrity of the archive and exit. -x, --extract-only Extract the contents of ./NVIDIA-Linux-x86_64-375.26.run, but do not run 'nvidia-installer'. The following arguments will be passed on to the ./nvidia-installer utility: -a, --accept-license Bypass the display and prompting for acceptance of the NVIDIA Software License Agreement. By passing this option to nvidia-installer, you indicate that you have read and accept the License Agreement contained in the file 'LICENSE' (in the top level directory of the driver package). --update Connect to the NVIDIA FTP server ' ftp://download.nvidia.com ' and determine the latest available driver version. If there is a more recent driver available, automatically download and install it. Any other options given on the commandline will be passed on to the downloaded driver package when installing it. -v, --version Print the nvidia-installer version and exit. -h, --help Print usage information for the common commandline options and exit. -A, --advanced-options Print usage information for the common commandline options as well as the advanced options, and then exit.
「--advanced-options
」--info
」--list
」
$ ./NVIDIA-Linux-x86_64-375.26.run --info Identification : NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26 Target directory : NVIDIA-Linux-x86_64-375.26 Uncompressed size : 332062 KB Compression : xz Date of packaging : Thu Dec 8 19:33:01 PST 2016 Application run after extraction : ./nvidia-installer The directory NVIDIA-Linux-x86_64-375.26 will be removed after extraction. $ ./NVIDIA-Linux-x86_64-375.26.run --list Target directory: NVIDIA-Linux-x86_64-375.26 drwxr-xr-x buildmeister/gopher 0 2016-12-09 12:33 ./kernel/ drwxr-xr-x buildmeister/gopher 0 2016-12-09 12:33 ./kernel/nvidia/ -rw-r--r-- buildmeister/gopher 16051512 2016-12-09 11:36 ./kernel/nvidia/nv-kernel.o_binary -rw-r--r-- buildmeister/gopher 119627 2016-12-09 10:17 ./kernel/nvidia/nv.c -rw-r--r-- buildmeister/gopher 43866 2016-12-09 10:17 ./kernel/nvidia/nv-acpi.c -rw-r--r-- buildmeister/gopher 803 2016-12-09 10:17 ./kernel/nvidia/nv-chrdev.c -rw-r--r-- buildmeister/gopher 7042 2016-12-09 10:17 ./kernel/nvidia/nv-cray.c -rw-r--r-- buildmeister/gopher 14781 2016-12-09 10:17 ./kernel/nvidia/nv-dma.c -rw-r--r-- buildmeister/gopher 3112 2016-12-09 10:17 ./kernel/nvidia/nv-gvi.c -rw-r--r-- buildmeister/gopher 8325 2016-12-09 10:17 ./kernel/nvidia/nv-i2c.c (中略) -rwxr-xr-x buildmeister/gopher 46812 2016-12-09 12:27 ./32/libGLESv1_CM_nvidia.so.375.26 -rwxr-xr-x buildmeister/gopher 191848 2016-12-09 12:27 ./32/libnvidia-ifr.so.375.26 -rwxr-xr-x buildmeister/gopher 85628 2016-12-09 11:03 ./32/libnvidia-fbc.so.375.26
実際にインストールスクリプトでインストーラーを実行する前に、
- カーネルのヘッダーファイル
- ビルドツール
- DKMS
NVIDIA製ドライバーは、
また、
$ sudo apt install dkms
あとはインストーラーを管理者権限で実行しましょう。NcursesベースのUIが起動しますので、/etc/
」--disable-nouveau
」
$ sudo ./NVIDIA-Linux-x86_64-375.26.run --disable-nouveau







nvidia-xconfig
を実行するかどうか

Ubuntuサーバーの場合はX Window Systemが存在しないため、nvidia-xconfig
の実行も不要です。また32ビットプログラムも不要なので、
「/etc/
」update-initramfs
コマンドを実行した上で
$ sudo update-initramfs -u $ sudo reboot
再起動後にnouveauドライバーがロードされていないこと、
$ lsmod | grep -i nouveau (何も表示されない) $ lsmod | grep -i nvidia nvidia_drm 53248 0 nvidia_modeset 790528 1 nvidia_drm nvidia 11943936 1 nvidia_modeset drm_kms_helper 155648 2 i915_bpo,nvidia_drm drm 364544 4 i915_bpo,drm_kms_helper,nvidia_drm $ modinfo nvidia filename: /lib/modules/4.4.0-59-generic/updates/dkms/nvidia.ko alias: char-major-195-* version: 375.26 supported: external license: NVIDIA srcversion: 7850503DF85713C6E0D88A3 alias: pci:v000010DEd00000E00sv*sd*bc04sc80i00* alias: pci:v000010DEd*sv*sd*bc03sc02i00* alias: pci:v000010DEd*sv*sd*bc03sc00i00* depends: vermagic: 4.4.0-59-generic SMP mod_unload modversions parm: NVreg_Mobile:int parm: NVreg_ResmanDebugLevel:int parm: NVreg_RmLogonRC:int parm: NVreg_ModifyDeviceFiles:int parm: NVreg_DeviceFileUID:int parm: NVreg_DeviceFileGID:int parm: NVreg_DeviceFileMode:int parm: NVreg_UpdateMemoryTypes:int parm: NVreg_InitializeSystemMemoryAllocations:int parm: NVreg_UsePageAttributeTable:int parm: NVreg_MapRegistersEarly:int parm: NVreg_RegisterForACPIEvents:int parm: NVreg_CheckPCIConfigSpace:int parm: NVreg_EnablePCIeGen3:int parm: NVreg_EnableMSI:int parm: NVreg_TCEBypassMode:int parm: NVreg_UseThreadedInterrupts:int parm: NVreg_MemoryPoolSize:int parm: NVreg_RegistryDwords:charp parm: NVreg_RmMsg:charp parm: NVreg_AssignGpus:charp
またnvidia-debugdump
コマンドやnvidia-smi
コマンドを使えば、
$ nvidia-debugdump -l Found 1 NVIDIA devices Device ID: 0 Device name: GeForce GTX 1050 Ti GPU internal ID: GPU-6fae1717-190c-1843-3fb8-c3d6cd190739 $ nvidia-smi Sun Jan 15 02:59:51 2017 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 375.26 Driver Version: 375.26 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 105... Off | 0000:01:00.0 Off | N/A | | 0% 40C P0 35W / 72W | 0MiB / 4038MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
NVIDIA製のインストーラースクリプトの場合、--update
」--latest
」
(最新版の有無を確認する場合:確認時も管理者権限が必要) $ sudo ./NVIDIA-Linux-x86_64-375.26.run --latest (ダウンロードして更新する場合) $ sudo ./NVIDIA-Linux-x86_64-375.26.run --update