計算の一部をGPUに回して処理速度を向上させる. そのプログラムを作るのに、動かすのに必要なのがこのCUDAライブラリ
Compute Unified Device Architecture
CUDA自体はnvidia社からリリースされ、nvidia社製VGAカードにのみ有効である.
CUDA | OS | GCC | ICC | HW | CLANG |
11.8.0 | RHEL9.0, RHEL8.6, RHEL7.9, ubuntu22.04, ubuntu20.04.4, ubuntu18.04.6 | gcc11まで対応 gcc6以上が推奨 | 2021 | 3.5 – 9.0 KeplerとMaxwellは非推奨, Pascal, Volta, Turing, Ampere, Ada, Hopper | 14.0 |
11.7.0 | RHEL8.5, RHEL7.9, ubuntu22.04, ubuntu20.04.4, ubuntu18.04.6 | gcc11まで対応 gcc6以上が推奨 | 2021 | 3.5 – 8.6 KeplerとMaxwellは非推奨, Pascal, Volta, Turing, Ampere | |
11.6.2 | RHEL8.5, RHEL7.9, ubuntu20.04.4, ubuntu18.04.6 | ||||
11.6.1 | RHEL8.5, RHEL7.9, ubuntu20.04.3, ubuntu18.04.6 | ||||
11.6.0 | |||||
11.5.1 | |||||
11.5.0 | RHEL8.4, RHEL7.9, ubuntu20.04.3, ubuntu18.04.5 | ||||
11.4.3 | |||||
11.4.2 | |||||
11.4.1 | RHEL8.4, RHEL7.9, ubuntu20.04.2, ubuntu18.04.5 | ||||
11.4.0 | gcc9 まで対応 gcc6以上が推奨 | 19.1 2020 | 3.5 – 8.6 KeplerとMaxwellは非推奨, Pascal, Volta, Turing, Ampere | ||
11.3.1 | RHEL8.3, RHEL7.9, ubuntu20.04.1, ubuntu18.04.5 | 3.5 – 8.6 Kepler (in part), Maxwell, Pascal, Volta, Turing, Ampere | |||
11.3.0 | gcc9 まで対応 gcc5以上が推奨* | 19.1 2020 | 3.5 – 8.6 Kepler (in part), Maxwell, Pascal, Volta, Turing, Ampere | ||
11.2.2 | |||||
11.2.1 | |||||
11.2.0 | |||||
11.1.1 | RHEL8.2, RHEL7.8, ubuntu20.04.1, ubuntu18.04.5 | ||||
11.1.0 | |||||
10.2.89 | RHEL8.1, RHEL7.7, ubuntu18.04.3 | 8 | 19.0 2018 | 3.0 – 7.5 Kepler, Maxwell, Pascal, Volta, Turing | |
10.1.243 | RHEL8.0, RHEL7.6, ubuntu18.04.3 | ||||
10.0.130 | RHEL7.5, ubuntu18.04.1 | 7 | 18.0 2017 | ||
9.2.148 | RHEL7.x, Ubuntu16.04.4 | 17.0 2016 | 3.0 – 7.2 Kepler, Maxwell, Pascal, Volta | ||
9.1.85 | RHEL7.x, Ubuntu16.04 | 6 | |||
9.0.176 | |||||
8.0 | RHEL7.x, Ubuntu16.04 | 5.3 | 16 2015 | 2.0 – 6.x Fermi, Kepler, Maxwell, Pascal |
*https://docs.nvidia.com/cuda/archive/11.0/cuda-installation-guide-linux/index.html
c++の各バージョンでの言語機能実装状況(c++11とかc++14、c++17、c++20など)
https://cpprefjp.github.io/implementation-status.html
あとCUDAのバージョンで適用できるOSも限定されているようで、もしOSに適合しないCUDAを入れた場合下記のようなメッセージが出る
実質はCUDAドライバーとOSの組み合わせと思うのだが...
[ 10.253873] NVRM: The NVIDIA GPU 0000:13:00.0 (PCI ID: 10de:2531)
NVRM: installed in this system is not supported by the
NVRM: NVIDIA 465.19.01 driver release.
NVRM: Please see 'Appendix A - Supported NVIDIA GPU Products'
NVRM: in this release's README, available on the operating system
NVRM: specific graphics driver download page at www.nvidia.com.
[ 10.254137] nvidia: probe of 0000:13:00.0 failed with error -1
[ 10.254150] NVRM: The NVIDIA probe routine failed for 1 device(s).
下記サイトからCUDAライブラリを入手します
https://developer.nvidia.com/cuda-downloads
インストール用ファイルは
と3種類ありますが、ここでは「rpm(local)」をいつも使用しています.
CUDAを機能させるためにはNVIDIAドライバが必要です。
これらインストール用ファイルには NVIDIAドライバ を含み一度でドライバとライブラリを入れれますが、NVIDIAドライバが古かったりします.
ここではNVIDIAのように、NVIDIAドライバのみを先行してインストールして、あとからCUDAライブラリを入れております.
「rpm(local)」の場合は、rpmファイルを取得して、localinstallでリポジトリのインストール、その後必要なパッケージをインストールしています
「必要なパッケージ」は「cuda-toolkit」です. この「cuda-toolkit」でnvccやcudaライブラリ(開発/実行)がインストールされます
dnf localinstall cuda-repo-rhel9-12-1-local-12.1.0_530.30.02-1.x86_64.rpm
dnf install cuda-toolkit-12-1
dnf remove cuda-repo-rhel9-12-1-local-12.1.0_530.30.02-1 <-- 「必要なパッケージ」のインストールが終わったらリポジトリを削除します
もし、実行ライブラリのみ必要だったら「cuda-libraries」のみを入れます. これでランタイムライブラリのみ入ります.
Gautomatch, GCTFにおいては、cuda-libraries-10-1があればいい
nvidiaドライバとcudaライブラリを一緒に入れてみる.
まずは nouveau を強制的に外して、multi-user.targetに切り替える
[root@centos7 ~]# vi /etc/default/grub
:
GRUB_CMDLINE_LINUX="rhgb quiet"
↓
GRUB_CMDLINE_LINUX="rhgb quiet nouveau.modeset=0 modprobe.blacklist=nouveau"
:
[root@centos7 ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
[root@centos7 ~]# systemctl set-default multi-user.target
[root@centos7 ~]# reboot
[root@centos7 ~]# yum install epel-release -y; yum install dkms -y
[root@centos7 ~]# bash /Public/cuda/cuda_12.1.0_530.30.02_linux.run --driver --kernelobjects --toolkit --no-opengl-libs --no-man-page --silent
[root@centos7 ~]# systemctl set-default graphical.target ; reboot
conda経由で作れるcrYOLOやtopazにはcudaライブラリが必要ですが、別に/usr/local/cudaが必要なわけではない.
cudaの中で独自にcudaライブラリを用意するから. nvidiaドライバは必須ですけど.
なら必要な局面は?となるとrelionとか自らコンパイルするとか自作プログラムを作る際には/usr/local/cudaが必要となる
CUDAの動作モード.
cudaライブラリのパッケージから入れるか、nvidiaドライバを入れてからcudaのtoolkitのみを入れるかになる
前者は「Persistence Mode」のツールも入れてくれるが、後者は入らない。
後者の場合 https://download.nvidia.com/XFree86/nvidia-persistencedにてnvidiaドライバと同じバージョンのツールを取得する
bash NVIDIA-Linux-x86_64-520.56.06.run --disable-nouveau --no-opengl-files --no-libglx-indirect
reboot
tar xf nvidia-persistenced-520.56.06.tar.bz2 <-- 取得したファイル
cd nvidia-persistenced-520.56.06
make
make install
cd init
make install <--- 「nvidia-persistenced.service」がインストールされる
コンパイラ環境でもあるので modulefile を用意します
[root@rockylinux9 ~]# mkdir /apps/modulefiles/cuda
[root@rockylinux9 ~]# vi /apps/modulefiles/cuda/12.1
#%Module1.0
set cuda /usr/local/cuda-12.1
prepend-path PATH $cuda/bin
prepend-path LD_LIBRARY_PATH $cuda/lib64
prepend-path MANPATH $cuda/share/man
[root@rockylinux9 ~]#
LD_LIBRARY_PATH は「/etc/ld.so.conf.d/」で定義されているから不要かもしれない