카테고리 없음

딥러닝 CUDA 설정 1, 2, 3

olive's 2022. 10. 26. 10:52

사전 정리 !!

$ sudo rm /etc/apt/sources.list.d/cuda*

$ sudo apt --purge autoremove nvidia*

$ sudo apt remove --autoremove nvidia-cuda-toolkit

 

 

1. DRIVER 설치 

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:1c.4/0000:02:00.0 ==
modalias : pci:v000010DEd00002182sv000019DAsd00004527bc03sc00i00
vendor   : NVIDIA Corporation
model    : TU116 [GeForce GTX 1660 Ti]
driver   : nvidia-driver-515-open - distro non-free
driver   : nvidia-driver-510-server - distro non-free
driver   : nvidia-driver-520-open - distro non-free recommended
driver   : nvidia-driver-515-server - distro non-free
driver   : nvidia-driver-510 - third-party non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-520 - third-party non-free
driver   : nvidia-driver-515 - third-party non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

 

$sudo add-apt-repository ppa:graphics-drivers/ppa

$sudo apt-get install nvidia-driver-{선택버전} 

재부팅후 확인 

$nvidia-smi 

 

2. CUDA toolkit 설치 

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

CUDA설치 중에 드라이버가 교체 설치되기도 한다. 

 

 

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

$sudo dpkg -i cudnn*.deb 

 

** 혹시 다음과 같이 에러가 난다면 

$ sudo dpkg -i cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb 
(데이터베이스 읽는중 ...현재 220467개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb ...
Unpacking cudnn-local-repo-ubuntu2204-8.5.0.96 (1.0-1) over (1.0-1) ...
cudnn-local-repo-ubuntu2204-8.5.0.96 (1.0-1) 설정하는 중입니다 ...

The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo cp /var/cudnn-local-repo-ubuntu2204-8.5.0.96/cudnn-local-7ED72349-keyring.gpg /usr/share/keyrings/

1. 첫번째 시도 

$sudo cp /var/cudnn-local-repo-ubuntu2204-8.5.0.96/cudnn-local-7ED72349-keyring.gpg /usr/share/keyrings/

$ sudo dpkg -i cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb 

이래도 같은 에러가 난다면 

 

 

2. 두번째 시도

다음과 같이 이름을 바꾸서 저장하고 다시 설치 시도한다. 

$ sudo cp /var/cudnn-local-repo-ubuntu2204-8.5.0.96/cudnn-local-7ED72349-keyring.gpg /usr/share/keyrings/cuda-archive-keyring.gpg

$ sudo dpkg -i cudnn-local-repo-ubuntu2204-8.5.0.96_1.0-1_amd64.deb 

 

 

**설정 마치고 재부팅 했는데도 nvcc -V가 보이지 않을 때 

1. ~/.bashrc 의 마지막에 환경 파일 설정추가하기 

export PATH="/usr/local/cuda-11.8/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH"

 

2. 환경 재 실행하기 

$source ~/.bashrc