Monday, May 21, 2018

Menginstall library CUDA 9.2 dan CuDNN 6 pada Ubuntu 16.04

Catatan singkat instalasi CUDA 8 (Upgaded ke 9.2) 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

Untuk instalasi CUDA 9.2, baca bagian bawah tulisan ini.

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 `nvcc-version` dan `watch nvidia-smi`:

Output nvcc:
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2017
Cuda compilation tools, release 8.0, V8.0.61
Ouput watch nvidia-smi:
$ 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.

Update 9 Juli 2018: Downgrade ke CUDA 7.5
Karena masalah "low graphic mode", NVIDIA saya upgrade ke versi 396.24.02 via software & updates >> Additional driver (update secara grafis, bukan melalui terminal). Sampai saat ini masih berjalan dengan baik.

Setelah itu, saya menginstall nvcc melalui repository (downgrade CUDA ke versi 7.5),
sudo apt install nvidia-cuda-toolkit 
Untuk mengeceknya gunakan,
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

Update 1 Agustus 2018: Upgrade ke CUDA 9.2

Langkah-langkah:
  1. Uninstall nvcc, `sudo apt autoremove nvidia-cuda-toolkit`
  2. Download deb installer (network), `wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.148-1_amd64.deb`
  3. `sudo dpkg -i cuda-repo-ubuntu1604_9.2.148-1_amd64.deb`
  4. `sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub`
  5. `sudo apt-get update`
  6. `sudo apt-get install cuda`
  7. Tambahkan path berikut di ~/.profile, `  PATH="/usr/local/cuda-9.2/bin:$HOME/bin:$HOME/.local/bin:$PATH" `
Selesai. Cek kembali dengan `nvcc --version`.



  • https://yangcha.github.io/Install-CUDA8/



  • Related Posts Plugin for WordPress, Blogger...