CUDA 10.1 & cuDNN 7.6.5 for Ubuntu 18.04

Changyeol Choi·2021년 1월 19일
0

GPU

목록 보기
4/4

1. Library 지원 버전 결정


Tensorflow

The following NVIDIA® software must be installed on your system:

NVIDIA® GPU drivers — CUDA 10.1 requires 410.x or higher.
CUDA® Toolkit —TensorFlow supports CUDA 10.0(TensorFlow >= 1.13.0)
CUPTI ships with the CUDA Toolkit.
cuDNN SDK (>= 7.4.1)


Pytorch

Python 3.5, 3.6, 3.7
CUDA 9.2, 10.1


Keras

Python 2.7-3.6


설치 항목

위에서 지원되는 모든 항목의 공통 분모는 다음과 같다.

  • Python 3.6
  • CUDA 10 or CUDA 10.1
  • cuDNN (>=7.4.1)

따라서 CUDA 10.1, cuDNN 7.6.5 로 결정한다.


2. Start Clean

Ubuntu 18.04의 경우 nvidia 드라이버가 자동 설치되지 않는다. 그리고 드라이버와 cuda를 빈번하게 재설치할 경우 패키지 dependencies가 깨질 수 있다.

$ sudo apt purge nvidia*
$ sudo apt remove nvidia-*
$ sudo rm /etc/apt/sources.list.d/cuda*
$ sudo apt autoremove && apt autoclean
$ sudo rm -rf /usr/local/cuda*  

3. 필요 패키지 설치

CUDA 설치시 다음과 같은 dependency는 미리 설치해두는 것이 좋다.

$ sudo apt-get update
$ sudo apt-get install build-essential dkms g++ 
$ sudo apt install -y freeglut3 freeglut3-dev libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev  

4. CUDA 저장소 등록

PPA(Personal Package Archive)를 사용한다.

$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
$ echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list  

Run update

sudo apt update

다음 명령으로 현재 사용중인 그래픽 카드에 설치할 수 있는 드라이버를 확인합니다.

$ ubuntu-drivers devices

현재 PC에서 GeForce GTX 1660 Ti를 사용중이고 추천하는 드라이버는 nividia-driver-440임을 알 수 있습니다.

driver 항목 중 recommended가 붙은 드라이버를 선택하면 됩니다.

Install Nvidia Driver 440

sudo apt install -y nvidia-driver-440

Install CUDA-10.1

sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-1 cuda-drivers

Set CUDA paths

echo 'export PATH=/usr/local/cuda-10.1/bin:PATH>> /.bashrcechoexportLDLIBRARYPATH=/usr/local/cuda10.1/lib64:PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

Download Cudnn 7.6.5 for CUDa 10.1

  • Go to https://developer.nvidia.com/cudnn
  • Create an account
  • Download the suitable version of Cudnn from https://developer.nvidia.com/rdp/cudnn-download
  • Extract the downloaded file tar -xzvf <filename>
  • Copy the following files into the CUDA directory
    sudo cp -P cuda/include/cudnn.h /usr/local/cuda-10.1/include
    sudo cp -P cuda/lib64/libcudnn /usr/local/cuda-10.1/lib64/
    sudo chmod a+r /usr/local/cuda-10.1/lib64/libcudnn

Restart the PC

Restart your PC to apply the changes

Check that everything went the right way

nvidia-smi
nvcc -V

설치 확인

CUDA 확인

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

cuDNN 확인

$ ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep libcudnn
libcudnn.so.7 -> libcudnn.so.7.6.5

또는

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"
profile
10년 후...내 모습을 위한 첫걸음

0개의 댓글