본문 바로가기
Ubuntu

[Ubuntu] ubuntu 18.04에 Graphic Driver, CUDA, cudnn 설치

by yongee97 2022. 10. 23.

* PC 사양 및 우분투 정보

- i9-12900

- NVIDIA GeForce RTX 3070 Ti

- Ubuntu 18.04

 

* 아래 항목을 설치

- nvidia graphic driver

- cuda

- cudnn

 

0. Version Check

- 설치를 마친 다음 버전을 확인하는 것이 목적

 

* Graphic Driver 470

nvidia-smi

* Cuda 11.4

nvcc -V

* cudnn 8.2.4

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

 

1. graphic driver 설치

sudo apt update
sudo apt-get install nvidia-driver-470

 

2. cuda 설치

* 설치 사이트

https://developer.nvidia.com/cuda-toolkit-archive

 

CUDA Toolkit Archive

Previous releases of the CUDA Toolkit, GPU Computing SDK, documentation and developer drivers can be found using the links below. Please select the release you want from the list below, and be sure to check www.nvidia.com/drivers for more recent production

developer.nvidia.com

linux - x86_64 - Ubuntu - 18.04 - runtime(local)

# this could be different based on your desired cuda install version
# I recommend you to go to the upper site and follow instructions there.
wget https://developer.download.nvidia.com/compute/cuda/11.4.4/local_installers/cuda_11.4.4_470.82.01_linux.run
sudo sh cuda_11.4.4_470.82.01_linux.run

중요 : cuda 설치할 때 driver는 이미 설치했으므로 선택하지 말 것!

 

추가로 설치 확인을 위해 툴킷 설치

sudo apt install nvidia-cuda-toolkit

이후 bashrc에 cuda Path 명시

아래 내용을 bashrc에 추가할 것!

# gedit ~/.bashrc
export PATH="/usr/local/cuda-11.6/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.6/lib64:$LD_LIBRARY_PATH"

3. cudnn 설치

* 설치 사이트

https://developer.nvidia.com/rdp/cudnn-archive

 

cuDNN Archive

Download releases from the GPU-accelerated primitive library for deep neural networks.

developer.nvidia.com

Local installer for Linux_x84_64 [Tar] 선택 후 다운로드

tar xvf cudnn-11.4-linux-x64-v8.2.4.15.tgz
cd cuda

현재 cuda가 설치된 디렉터리 안 include 폴더에 cnn 파일을 복사-붙여넣기

나같은경우에는 cuda 11.4 설치되어 있고, 해당하는 경로는 /usr/local/cuda-11.4/

혹시나 cuda 설치 버전이 다른 경우에는 /usr/local에 들어가서 확인 가능

 

다음 명령어를 실행해서 복사-붙여넣기

# current folder is cuda
sudo cp include/cudnn* /usr/local/cuda-11.4/include
sudo cp lib64/libcudnn* /usr/local/cuda-11.4/lib64
sudo chmod a+r /usr/local/cuda-11.4/lib64/libcudnn*

 

끝.