とらりもんHOME  Index  Search  Changes  Login

GPU

Ubuntu Linux 20.04 + GeForce RTX 3060

ドライバのインストール

$ sudo apt install nvidia-driver-465 nvidia-settings

いろいろチェック

$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GA106 [GeForce RTX 3060] (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 228e (rev a1)
$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  470.57.02  Tue Jul 13 16:14:05 UTC 2021
GCC version:  gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
$ watch "nvidia-smi" 
Every 2.0s: nvidia-smi                          nasahome2: Sun Sep  5 20:06:08 2021
Sun Sep  5 20:06:08 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.57.02    Driver Version: 470.57.02    CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| 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 ...  Off  | 00000000:01:00.0  On |                  N/A |
|  0%   39C    P8    16W / 170W |    691MiB / 12051MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1256      G   /usr/lib/xorg/Xorg                 35MiB |
|    0   N/A  N/A      1919      G   /usr/lib/xorg/Xorg                339MiB |
|    0   N/A  N/A      2060      G   /usr/bin/gnome-shell               38MiB |
|    0   N/A  N/A      2409      G   /usr/lib/firefox/firefox          175MiB |
|    0   N/A  N/A      2637      G   ...AAAAAAAA== --shared-files       15MiB |
|    0   N/A  N/A      2674      G   ...AAAAAAAAA= --shared-files       32MiB |
|    0   N/A  N/A      2772      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      2886      G   /usr/lib/firefox/firefox            2MiB |
|    0   N/A  N/A      6627      G   ...AAAAAAAAA= --shared-files       20MiB |
|    0   N/A  N/A     15523      G   .../debug.log --shared-files        7MiB |
|    0   N/A  N/A     38876      G   /usr/lib/firefox/firefox            4MiB |
|    0   N/A  N/A     43349      G   /usr/lib/firefox/firefox            2MiB |
+-----------------------------------------------------------------------------+

CUDAのインストール

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_network

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
$ sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
$ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
$ sudo apt-get update
$ sudo apt-get -y install cuda

CUDAツールキットのインストール

$ sudo apt install nvidia-cuda-toolkit

# チェック
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

$ lspci | grep -i nvidia でGPUの型番が出てこない時:

nishida@tochinoki:~$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1e81 (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 10f8 (rev a1)
01:00.2 USB controller: NVIDIA Corporation Device 1ad8 (rev a1)
01:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device 1ad9 (rev a1)
# 解決策:
nishida@tochinoki:~$ sudo update-pciids
Downloaded daily snapshot dated 2020-02-10 03:15:02
nishida@tochinoki:~$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation TU104 [GeForce RTX 2080 SUPER] (rev a1)
01:00.1 Audio device: NVIDIA Corporation TU104 HD Audio Controller (rev a1)
01:00.2 USB controller: NVIDIA Corporation TU104 USB 3.1 Host Controller (rev a1)
01:00.3 Serial bus controller [0c80]: NVIDIA Corporation TU104 USB Type-C UCSI Controller (rev a1)

Install CUDA in Ubuntu 16.04 (2018/06/05, 2019/03/23 K Nasahara)

export PATH=/usr/local/cuda/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Then reboot! After that, check the following!

  • lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)
  • nvidia-smi -L
GPU 0: GeForce GTX 650 (UUID: GPU-6fa3b725-060c-0f7c-43e0-08d66033f6b4)

Things to do, after you got graphic board. 2017/12/15 Ishibashi

Check the GPU hardware

$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)

Nvidia and CUDA installation.

sudo apt-cache search 'nvidia-[0-9]+$'
↑It shows available nvidia driver versions.
sudo apt-get install nvidia-??? # you choose one driver version.
sudo apt-get install nvidia-387
sudo apt-get install nvidia-387-dev
sudo apt-get install nvidia-modprobe
sudo apt-get install nvidia-opencl-icd-387
sudo apt-get install nvidia-prime
sudo apt-get install nvidia-settings

you can download CUDA installer here.
"runfile" is used in this case below.

./cuda_9.1.85_387.26_linux.run

## Write those sentences below on ".bashrc".
export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda

sudo apt-get install cuda
sudo apt update
sudo apt upgrade
sudo reboot now

Helpful commands

# GPU model.
nvidia-smi
lspci | grep -i nvidia

# watch GPU working
watch -n1 "nvidia-smi"
# Nvidia driver version.
cat /proc/driver/nvidia/version

# CUDA version.
nvcc -V

# Installed packages.
dpkg -l | grep cuda
dpkg -l | grep nvidia

install other packages.

pip install cupy --no-cache-dir -vvvv
# sudo apt install nvidia-cuda-toolkit # This command is somehow destructive.
sudo apt install nvidia-cuda-toolkit

Last modified:2021/09/05 20:14:27
Keyword(s):
References: