1
1

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 1 year has passed since last update.

[Linux] ubuntu20.04のPCにCUDA, cudnnをインストールする

Last updated at Posted at 2023-01-11

やること

例としてubuntu20.04のPCにCUDA11.3, cudnn8.4.1をインストールする。

手順

CUDA

参考手順はこちら

以下のコマンドを実行

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
wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda-11.3

sudo apt-get update 時に以下のエラーが出た場合、
image.png

こちらを参照に解決する。

cudnn

参照手順はこちら
cudnn, cudaの対応関係は、こちらからたどる

こちらのDownload cuDNN v8.4.1 (May 27th, 2022), for CUDA 11.x」->「Local Installer for Linux x86_64 (Tar)」から、tarをカレントディレクトリにダウンロード

・次に以下のコマンドを実行

tar -xvf cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive.tar.xz
sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda-11.3/include
sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda-11.3/lib64 
sudo chmod a+r /usr/local/cuda-11.3/include/cudnn*.h /usr/local/cuda-11.3/lib64/libcudnn*

環境変数の設定

・以下のコマンドを実行

sudo nano ~/.bashrc

.bashrcに以下を追加
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

Crtl o Enter で編集完了
Ctrl x で閉じる

source ~/.bashrcで有効化し、nvcc -Vで cuda 11.3が表示されることを確認

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?