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)
Python 3.5, 3.6, 3.7
CUDA 9.2, 10.1
Python 2.7-3.6
위에서 지원되는 모든 항목의 공통 분모는 다음과 같다.
따라서 CUDA 10.1, cuDNN 7.6.5 로 결정한다.
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*
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
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
sudo apt update
다음 명령으로 현재 사용중인 그래픽 카드에 설치할 수 있는 드라이버를 확인합니다.
$ ubuntu-drivers devices
현재 PC에서 GeForce GTX 1660 Ti를 사용중이고 추천하는 드라이버는 nividia-driver-440임을 알 수 있습니다.
driver 항목 중 recommended가 붙은 드라이버를 선택하면 됩니다.
sudo apt install -y nvidia-driver-440
sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-1 cuda-drivers
echo 'export PATH=/usr/local/cuda-10.1/bin:LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig
tar -xzvf <filename>
Restart your PC to apply the changes
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"