Monday, May 21, 2018

Menginstall library CUDA 8 dan CuDNN 6 pada Ubuntu 16.04

Catatan singkat instalasi CUDA 8 dan CuDNN 6 pada Ubuntu 16.04 Xenial Xerus.

OS: Ubuntu 16.04.4 LTS, 64-bit
CPU:  i9-7900X CPU @ 3.30GHz × 20
GPU: GeForce GTX 1060 6GB/PCIe/SSE2

Langkah-langkah instalasi

Jalankan langkah-langkah berikut pada terminal, saya sarankan anda berada di "/tmp".
$ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn6_6.0.21-1%2Bcuda8.0_amd64.deb
$ wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn6-dev_6.0.21-1%2Bcuda8.0_amd64.deb
$ sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
$ sudo dpkg -i libcudnn6_6.0.21-1+cuda8.0_amd64.deb
$ sudo dpkg -i libcudnn6-dev_6.0.21-1+cuda8.0_amd64.deb

Kemudian tambahkan path instalasi di ~/.bashrc seperti berikut:
$ vim .bashrc
Anda bisa meggunakan Gedit jika tidak ingin menggunakan vim.
# cuda path
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Untuk mengeceknya, gunakan perintah `watch`:

$ watch nvidia-smi
Mon May 21 23:13:17 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111                Driver Version: 384.111                   |
|-------------------------------+----------------------+----------------------+
| 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 106...  Off  | 00000000:65:00.0  On |                  N/A |
| 24%   41C    P8     6W / 120W |    328MiB /  6069MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1291      G   /usr/lib/xorg/Xorg                           169MiB |
|    0      1792      G   compiz                                       155MiB |
|    0      2171      G   /opt/teamviewer/tv_bin/TeamViewer              1MiB |
+-----------------------------------------------------------------------------+

Alhamdulillah, jika anda melihat seri dari GPU yang terpasang (misal seperti diatas GTX 1060) beserta penggunaan powernya, berarti driver CUDA telah terinstall dengan proper.

Note:
CUDA 8 bukan merupakan CUDA terbaru, per tulisan ini ditulis, yang versi terbaru adalah CUDA 9.2. Versi 8 saya butuhkan agar "it works" saja di komputer saya. Begitu juga dengan CuDNN 6.

Referensi:
  1. https://yangcha.github.io/Install-CUDA8/
Related Posts Plugin for WordPress, Blogger...