Ubuntu 18.04にCuda 9.0とcuDNN v7.4をインストール

# 必要なパッケージを色々インストール
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

# CUDA 9 のインストールに必要な gcc 6 をインストール
sudo apt install gcc-6
sudo apt install g++-6

# cuda toolkitをダウンロード
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run

# 権限追加、実行
chmod +x cuda_9.0.176_384.81_linux.run 
sudo ./cuda_9.0.176_384.81_linux.run --override

長い文をスクロールしたあと、色々答える。

Do you accept the previously read EULA?
accept/decline/quit: accept

You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: yes

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: no

Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: yes

Enter Toolkit Location
 [ default is /usr/local/cuda-9.0 ]: 

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yes

Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: yes

Enter CUDA Samples Location
 [ default is /home/hgsyo76 ]: 

Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...

# gcc/g++のsymlinksを設定。
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++

# パスを通す。
echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

# cuDNN をインストール 
#"https://developer.nvidia.com/developer-program/signup"で会員登録をし、ログインする。
#そして"https://developer.nvidia.com/cudnn"でcuDNN Library for Linuxをダウンロード。
#ファイルの展開
tar -zxvf cudnn-9.0-linux-x64-v7.4.1.5.tgz 

# cuda toolkitディレクトリにファイルをコピー
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn*

#確認
nvidia-smi
nvcc -V

hgsyo76@hgsyo76:~/Downloads$ nvidia-smi
Mon Dec  3 14:50:50 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.87                 Driver Version: 390.87                    |
|-------------------------------+----------------------+----------------------+
| 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 MX150       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   52C    P0    N/A /  N/A |   1112MiB /  2002MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1307      G   /usr/lib/xorg/Xorg                           635MiB |
|    0      1832      G   /usr/bin/compiz                              255MiB |
|    0     23441      G   ...uest-channel-token=12728558105107124850   165MiB |
|    0     25688      G   ...-token=7619D289940C102F79060D9A29C0B0D4    55MiB |
+-----------------------------------------------------------------------------+
hgsyo76@hgsyo76:~/Downloads$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

おつかれさまでした

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です