Ubuntu에서 CUDA 설치하기
최초 작성일: 2021.01.31.
1. 개요
OS : Ubuntu, Windows
모든 명령어는 터미널에서 입력
CUTA Toolkit 버전 : 10.1
cuDNN 버전 : 7.6.5
cuDNN 버전 상세
- cuDNN v7.6.5 (November 5th, 2019), for CUDA 10.1
- cuDNN Developer Library for Ubuntu18.04 (Deb)
2. CUDA 10.1 설치
2.1 CUDA 10.1 확인
CUDA Toolkit 10.1 update2 Archive
Select Target Platform Click on the green buttons that describe your target platform. Only supported platforms will be shown. Operating System Architecture Distribution Version Installer Type Do you want to cross-compile? Yes No Select Host Platform Click
developer.nvidia.com
![]() |
설치 코드가 보인다고 바로 입력하기 보다는 아래에 보이는 Installation Guide for Linux를 보자.
2.2 CUDA 10.1 요구사항 확인
아래에 10.1 버전 가이드로 가져왔다.
Installation Guide Linux :: CUDA Toolkit Documentation
Check that the device files/dev/nvidia* exist and have the correct (0666) file permissions. These files are used by the CUDA Driver to communicate with the kernel-mode portion of the NVIDIA Driver. Applications that use the NVIDIA driver, such as a CUDA ap
docs.nvidia.com
요구사항은 다음과 같다.
- CUDA-capable GPU
- A supported version of Linux with a gcc compiler and toolchain
- NVIDIA CUDA Toolkit (available at http://developer.nvidia.com/cuda-downloads)
Windows와는 달리 Visual Studio 2019가 필요하지 않고 gcc compiler와 toolchain만 필요한 것을 볼 수 있다.
2.2.1 CUDA-capable GPU 확인
CUDA GPUs
Recommended GPU for Developers NVIDIA TITAN RTX NVIDIA TITAN RTX is built for data science, AI research, content creation and general GPU development. Built on the Turing architecture, it features 4608, 576 full-speed mixed precision Tensor Cores for accel
developer.nvidia.com
![]() |
링크에 들어가서 Tesla, Quadro, NVS, GeForce and TITAN, Jetson 중 자신의 GPU 분류를 선택한 다음 자신의 GPU가 Compute Capability 버전이 몇인지 확인한다. 정확하진 않지만 3.5 이상이면 전부 되는 것으로 보인다.
2.2.2 gcc compiler 설치
sudo apt update
sudo apt install build-essential
gcc --version
1. 패키지 업데이트
sudo apt-get update
2. gcc 컴파일러와 기타 요소 설치
sudo apt-get install build-essential
3. 설치 확인 및 버전 확인
gcc --version
2.2.3 toolchain
toolchain? 뭔지 모르겠다. 검색해도 잘 안보인다.
2.3 CUDA 10.1 설치
이전 2.1에서 봤던 명령어를 입력한다.
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
3. cuDNN 7.6.5
3.1 cuDNN 7.6.5 다운
NVIDIA cuDNN
NVIDIA cuDNN The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, norma
developer.nvidia.com
cuDNN을 다운받는다. 엔비디아 계정이 필요하다.
나는
이 둘을 다운받았다.
3.2 cuDNN 7.6.5 설치
cd Downloads
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.1_amd64.deb
dev 버전은 run 버전에 종속적이기 때문에 run 버전을 먼저 설치하고 dev 버전을 그 다음 설치해야한다.
4. 기타
혹시 추후 어디에서든지 에러가 난다면
cd /usr/include
nano cudnn.h
/usr/include/cudnn.h 파일에 있는
#include "driver_types.h" 를
#include <driver_types.h>로 바꿔본다.
CUDA와 관련 없는 에러처럼 보이다가도 위처럼 바꿔주면 사라지는 경우가 많다.
에러가 생기기 전에 미리 바꿔놓는 것을 권장한다.
'인공지능 > 딥러닝' 카테고리의 다른 글
Windows에서 PyTorch GPU 설치하기(CUDA) (0) | 2021.07.30 |
---|---|
Windows에서 GPU 지원 TensorFlow 설치하기(CUDA) (0) | 2020.08.24 |