32
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu18.04にNvidia Driver, CUDA, cuDNNを入れる

Last updated at Posted at 2018-06-17

Ubuntu 18.04 LTSでNvidia Driver, CUDA, cuDNNを入れる際、色々苦戦したのでこちらでまとめておきます。なお、Ubuntuのインストールは完了している前提で話を進めます。

今回試した環境

  • Ubuntu 18.04 LTS
  • NVIDIA GeForce GTX 1070 Ti
  • nvidia-driver 390.48
  • CUDA 9.1
  • cuDNN 7.1.2

nvidia-driver導入手順

# これ一発でインストールできる
$ sudo ubuntu-drivers autoinstall

# インストールが終わったら再起動
$ sudo reboot

# 確認
$ nvidia-smi
Mon Jun 18 02:09:02 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48                 Driver Version: 390.48                    |
|-------------------------------+----------------------+----------------------+
| 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 107...  Off  | 00000000:01:00.0  On |                  N/A |
|  1%   53C    P0    38W / 180W |    358MiB /  8116MiB |      1%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1136      G   /usr/lib/xorg/Xorg                            18MiB |
|    0      1187      G   /usr/bin/gnome-shell                          76MiB |
|    0      1957      G   /usr/lib/xorg/Xorg                           112MiB |
|    0      2102      G   /usr/bin/gnome-shell                         137MiB |
+-----------------------------------------------------------------------------+

CUDA導入手順

# Ubuntu18.04のリポジトリからインストール
sudo apt install nvidia-cuda-toolkit nvidia-driver-390
sudo reboot

この方法だと、Ubuntu18.04である限り、CUDA9.1が入るみたい。

cuDNN導入手順

https://developer.nvidia.com/rdp/cudnn-archiveここからメンバー登録して、cuDNN v7.1.2 (Mar 21, 2018), for CUDA 9.1 & 9.2のdebパッケージをダウンロードする。

tar xzvf cudnn-8.0-linux-x64-v5.1.tgz 
sudo cp -a cuda/lib64/* /usr/lib/cuda/lib64/
sudo cp -a cuda/include/* /usr/lib/cuda/include/

.bashrcに以下を書き込む

## CUDA and cuDNN paths
export PATH=/usr/lib/cuda/bin:${PATH}
export LD_LIBRARY_PATH=/usr/lib/cuda/lib64:${LD_LIBRARY_PATH}

後始末

sudo apt autoremove
sudo apt clean
32
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?