Linux(CentOS8)にNVIDIA ドライバをインストール

November 3, 2020 – 5:49 pm

グラフィックボード搭載のGPUで高速演算ができるという。

自宅のLinux Server(CewntOS8)上の Nvidia製Graphic Board(GF-GT710-E2GB/HS)でどの程度のことができるか試してみることにした。うまくゆけば、機械学習のプラットフォームを構築することができるかもしれない。

当然、本格的にGPUを用いた機械学習(ML)には、計算コア数、メモリ容量などが大きいなど高性能のGPUを用いることが望まれるが、まずは手持ちのlow-endのグラフィックボードで試してみることにした。ここで、技術的な可能性が実感されたら、それなりのグラフィックボードを購入しようと考えている。

NVIDIAでは、GPUでの演算を可能にするCUDA(Cuda Unified Device Architecture)を公開しているが、これはグラフィックボードの型式に適合したドライバをインストールすることにより利用可能になる。

以下、NVIDIAのドライバをインストールした手続きについてメモしておいた。

ドライバインストールに必要な前処理
デフォルトでロードされている nouveauドライバーを無効にする:

[root@server02 ~]# vi /etc/modprobe.d/blacklist-nouvau.conf

最終行に以下を追記(ファイルのない場合新規作成)

blacklist nouveau
options nouveau modeset=0 

[root@server02 ~]# dracut --force

[root@server02 ~]# reboot

正常に無効になっていることを確認(何もでないことで確認)

[user@server02 ~]$  lsmod | grep -i nouveau
[user@server02 ~]$

NVIDIAダウンロードサイトからdriverを取得
NVIDIA公式サイトにアクセスし、手持ちのグラフィックボード用のドライバを検索する。

手持ちグラフィックの検索結果は以下:

LINUX X64 (AMD64/EM64T) DISPLAY DRIVER

バージョン: 450.80.02
リリース日: 2020.9.30
オペレーティングシステム: Linux 64-bit
言語: 134.52 MB
ファイルサイズ 134.52 MB

ダウンロードボタンのリンク先をコピーし、wgetでダウンロード

[user@server02 ~]# wget https://jp.download.nvidia.com/XFree86/Linux-x86_64/450.80.02/NVIDIA-Linux-x86_64-450.80.02.run
--2020-11-03 09:15:27--  https://jp.download.nvidia.com/XFree86/Linux-x86_64/450.80.02/NVIDIA-Linux-x86_64-450.80.02.run
Resolving jp.download.nvidia.com (jp.download.nvidia.com)... 2606:2800:247:2063:46e:21d:825:102e, 192.229.232.112
Connecting to jp.download.nvidia.com (jp.download.nvidia.com)|2606:2800:247:2063:46e:21d:825:102e|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 141055124 (135M) [application/octet-stream]
Saving to: ‘NVIDIA-Linux-x86_64-450.80.02.run’

NVIDIA-Linux-x86_64-450.80.02.ru 100%[=========================================================>] 134.52M  18.2MB/s    in 8.3s    

2020-11-03 09:15:36 (16.1 MB/s) - ‘NVIDIA-Linux-x86_64-450.80.02.run’ saved [141055124/141055124]

driverのインストール

[user@server02 ~]# bash NVIDIA-Linux-x86_64-450.80.02.run
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 450.80.02......................................................

ここでインストール作業が正常に進むと、インストール画面がたちあがるのでインストーラからの質問に応えるとdriverのインストール作業が終了する。

ただ、今回のインストール作業では、エラーに遭遇し、それなりの対応が必要になった。エラー内容、それへの対処法については後に説明することにする。

インストーラとの受け応え:

Install NVIDIA's 32-bit compatibility libraries?
     [Yes]                                   No

Would you like to run the nvidia-xconfig utility to automatically update
  your X configuration file so that the NVIDIA X driver will be used when you
  restart X?  Any pre-existing X configuration file will be backed up.
     [No]

Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64
  (version: 430.50) is now complete.  Please update your xorg.conf file as
  appropriate; see the file /usr/share/doc/NVIDIA_GLX-1.0/README.txt for
  details.
                                      [OK]

インストール時に遭遇したエラーと対処

[user@server02 ~]# bash NVIDIA-Linux-x86_64-450.80.02.run

で以下のエラー

ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that
they are properly configured; on Red Hat Linux systems, for example, be sure you have the ‘kernel-source’ or ‘kernel-devel’ RPM installed. If you know the
correct kernel source files are installed, you may specify the kernel source path with the ‘–kernel-source-path’ command line option.

エラーメッセージに基づき、–kernel-source patthを明記し、以下のコマンドを試す。

[user@server02 ~]# bash NVIDIA-Linux-x86_64-450.80.02.run --kernel-source-path=/usr/src/kernels/4.18.0-193.6.3.el8_2.x86_64

次に示すエラーが発生:

ERROR: Unable to load the kernel module ‘nvidia.ko’. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb, nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s).

このエラーは前項の –kernel-source-path に指定したところのkernelのソースがkernelと一致してないことによるもの。driverのインストールに際し、driverを反映したかたちでlinuxのkernelを書き換える必要があるので、kernelのsourceが必要。

kernel-devel, kernel-headerにある kernelは、動作しているkernelと異なるので、これを以下のコマンドで削除

rpm -e --nodeps 

kernelのsourceを取り込むため、動作しているkernelのrpmパッケージをさがし、これをダウンロードし、インストール。

以下、ダウンロード・インストール時のログを掲載:

[user@server02 ~]$ wget http://rpmfind.net/linux/centos/8.2.2004/BaseOS/x86_64/os/Packages/kernel-4.18.0-193.6.3.el8_2.x86_64.rpm
--2020-11-03 10:58:58--  http://rpmfind.net/linux/centos/8.2.2004/BaseOS/x86_64/os/Packages/kernel-4.18.0-193.6.3.el8_2.x86_64.rpm
Resolving rpmfind.net (rpmfind.net)... 195.220.108.108
Connecting to rpmfind.net (rpmfind.net)|195.220.108.108|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2900224 (2.8M) [application/x-rpm]
Saving to: ‘kernel-4.18.0-193.6.3.el8_2.x86_64.rpm’

kernel-4.18.0-193.6.3.el8_2.x86_64 100%[===============================================================>]   2.77M   512KB/s    in 7.0s    

2020-11-03 10:59:06 (403 KB/s) - ‘kernel-4.18.0-193.6.3.el8_2.x86_64.rpm’ saved [2900224/2900224]

正常にインストールされたことを確認

[root@server02 ~]# rpm -qa | grep kernel-devel
kernel-devel-4.18.0-193.6.3.el8_2.x86_64
[root@server02 ~]# ls -l /usr/src/kernels/
total 4
drwxr-xr-x 23 root root 4096 Oct 31 15:41 4.18.0-193.6.3.el8_2.x86_64

これで、前項 draiverのインストール で正常にインストール手続きが行うことができる。

なお、エラーへの対処については、Install Linux kernel-develを参照した。
  

 


Post a Comment