NVIDIA_RTXモデルのGPU使用状態確認手順
目的
NVIDIAのグラフィックボードRTXモデルのGPU使用状態をコマンドで確認する
参考
https://zenn.dev/190ikp/articles/how_to_install_nvidia_drivers
環境
- OS: ubuntu
- グラボ:NVIDIA GeForce RTX 3060
- ドライバ:cuda-drivers
- CUDA(Compute Unified Device Architecture:クーダ)とは、NVIDIAが開発・提供している、GPU向けの汎用並列コンピューティングプラットフォームおよびプログラミングモデルです。
手順
CUDAドライバを配布するリポジトリを登録してaptアップデートする
Ubuntu 18.04 LTSのCUDAリポジトリの公開鍵をダウンロードする
admin@server01:~$ curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/nvidia-cuda.gpg --import
gpg: keybox '/usr/share/keyrings/nvidia-cuda.gpg' created
gpg: directory '/root/.gnupg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key A4B469963BF863CC: public key "cudatools <cudatools@nvidia.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
admin@server01:~$
GPG公開鍵を登録する
admin@server01:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
Executing: /tmp/apt-key-gpghome.dAdlzICwYw/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
gpg: key A4B469963BF863CC: public key "cudatools <cudatools@nvidia.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
NVIDIA CUDA ToolkitのAPTリポジトリを/etc/apt/souces.list.d/cuda.listに追加する
admin@server01:~$ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list
deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /
admin@server01:~$ ll /etc/apt/sources.list.d
total 56
drwxr-xr-x 2 root root 4096 Nov 21 11:45 ./
drwxr-xr-x 7 root root 4096 Apr 9 2021 ../
-rw-r--r-- 1 root root 138 Nov 21 11:29 amdgpu.list
-rw-r--r-- 1 root root 138 Nov 21 11:29 amdgpu.list.save
-rw-r--r-- 1 root root 190 Nov 21 11:29 amdgpu-proprietary.list
-rw-r--r-- 1 root root 189 Nov 21 11:29 amdgpu-proprietary.list.save
-rw-r--r-- 1 root root 81 Nov 21 11:45 cuda.list
-rw-r--r-- 1 root root 142 Nov 21 11:29 graphics-drivers-ubuntu-ppa-focal.list
-rw-r--r-- 1 root root 78 Nov 21 11:29 rocm.list
-rw-r--r-- 1 root root 78 Nov 21 11:29 rocm.list.save
-rw-r--r-- 1 root root 136 Nov 21 11:29 ubuntu-x-swat-ubuntu-ppa-focal.list
-rw-r--r-- 1 root root 136 Nov 21 11:29 ubuntu-x-swat-ubuntu-ppa-focal.list.save
-rw-r--r-- 1 root root 116 Nov 21 11:29 zabbix.list
-rw-r--r-- 1 root root 116 Nov 21 11:29 zabbix.list.save
admin@server01:~$ cat /etc/apt/sources.list.d/cuda.list
deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /
aptアップデート
admin@server01:~$ sudo apt update
:
W: GPG error: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
E: The repository 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://ppa.launchpad.net/ubuntu-x-swat/ppa/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
エラーが出るので、以下コマンド実行。–recv-keysにエラーになった鍵を指定する
admin@server01:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
Executing: /tmp/apt-key-gpghome.dAdlzICwYw/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
gpg: key A4B469963BF863CC: public key "cudatools <cudatools@nvidia.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
CUDAドライバをインストールする
admin@server01:~$ sudo apt install -y cuda-drivers
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
正常性確認
nvidia-smiが使用できること
admin@server01:~$ nvidia-smi
Tue Nov 21 12:46:24 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03 Driver Version: 535.129.03 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 3060 Off | 00000000:0D:00.0 Off | N/A |
| 30% 32C P0 29W / 170W | 1MiB / 12288MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
The following additional packages will be installed:
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| No running processes found |
+---------------------------------------------------------------------------------------+