딥러닝 작업 환경

[Ubuntu 20.04 LTS] CUDA local설치

_펭구_ 2024. 1. 17. 15:24

Nvidia-driver를 설치를 진행 한후에 CUDA 설치를 진행한다. 

CUDA 설치를 진행하기전 2가지의 자료를 확인해 버전을 맞춰 줘야한다. 

1. CUDA와 Nvidia driver 버전 

2. CUDA와 compute capability 

이 두가지를 만족하는 CUDA를 설치해야한다. 


1. CUDA와 Nvidia driver 버전( CUDA Toolkit and Corresponding Driver Versions)

아래와 같이 driver에 따른 CUDA 버전을 확인한다.

CUDA Toolkit Toolkit Driver Version
  Linux x86_64 Driver Version Windows x86_64 Driver Version
CUDA 12.3 Update 2 >=545.23.08 >=546.12
CUDA 12.3 Update 1 >=545.23.08 >=546.12
CUDA 12.3 GA >=545.23.06 >=545.84
CUDA 12.2 Update 2 >=535.104.05 >=537.13
CUDA 12.2 Update 1 >=535.86.09 >=536.67
CUDA 12.2 GA >=535.54.03 >=536.25
CUDA 12.1 Update 1 >=530.30.02 >=531.14
CUDA 12.1 GA >=530.30.02 >=531.14
CUDA 12.0 Update 1 >=525.85.12 >=528.33
CUDA 12.0 GA >=525.60.13 >=527.41
CUDA 11.8 GA >=520.61.05 >=520.06
CUDA 11.7 Update 1 >=515.48.07 >=516.31
CUDA 11.7 GA >=515.43.04 >=516.01
CUDA 11.6 Update 2 >=510.47.03 >=511.65
CUDA 11.6 Update 1 >=510.47.03 >=511.65
CUDA 11.6 GA >=510.39.01 >=511.23
CUDA 11.5 Update 2 >=495.29.05 >=496.13
CUDA 11.5 Update 1 >=495.29.05 >=496.13
CUDA 11.5 GA >=495.29.05 >=496.04
CUDA 11.4 Update 4 >=470.82.01 >=472.50
CUDA 11.4 Update 3 >=470.82.01 >=472.50
CUDA 11.4 Update 2 >=470.57.02 >=471.41
CUDA 11.4 Update 1 >=470.57.02 >=471.41
CUDA 11.4.0 GA >=470.42.01 >=471.11
CUDA 11.3.1 Update 1 >=465.19.01 >=465.89
CUDA 11.3.0 GA >=465.19.01 >=465.89
CUDA 11.2.2 Update 2 >=460.32.03 >=461.33
CUDA 11.2.1 Update 1 >=460.32.03 >=461.09
CUDA 11.2.0 GA >=460.27.03 >=460.82
CUDA 11.1.1 Update 1 >=455.32 >=456.81
CUDA 11.1 GA >=455.23 >=456.38
CUDA 11.0.3 Update 1 >= 450.51.06 >= 451.82
CUDA 11.0.2 GA >= 450.51.05 >= 451.48
CUDA 11.0.1 RC >= 450.36.06 >= 451.22
CUDA 10.2.89 >= 440.33 >= 441.22
CUDA 10.1 (10.1.105 general release, and updates) >= 418.39 >= 418.96
CUDA 10.0.130 >= 410.48 >= 411.31
CUDA 9.2 (9.2.148 Update 1) >= 396.37 >= 398.26
CUDA 9.2 (9.2.88) >= 396.26 >= 397.44
CUDA 9.1 (9.1.85) >= 390.46 >= 391.29
CUDA 9.0 (9.0.76) >= 384.81 >= 385.54
CUDA 8.0 (8.0.61 GA2) >= 375.26 >= 376.51
CUDA 8.0 (8.0.44) >= 367.48 >= 369.30
CUDA 7.5 (7.5.16) >= 352.31 >= 353.66
CUDA 7.0 (7.0.28) >= 346.46 >= 347.62

https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#id4

 

CUDA 12.3 Update 2 Release Notes

BLAS level 2 and 3 functions might not treat alpha in a BLAS compliant manner when alpha is zero and the pointer mode is set to CUBLAS_POINTER_MODE_DEVICE. The expected behavior is that the corresponding computations would be skipped. You may encounter the

docs.nvidia.com


2. CUDA와 compute capability 

CUDA 버전과 GPU의 compute capability를 확인해야 한다. 문서는 길이가 있음으로 

간략하게 일부 사진만 첨부한다. 

https://en.wikipedia.org/wiki/CUDA

 

CUDA - Wikipedia

From Wikipedia, the free encyclopedia Parallel computing platform and programming model CUDA (or Compute Unified Device Architecture) is a proprietary and closed source parallel computing platform and application programming interface (API) that allows sof

en.wikipedia.org


다음으로 1, 2의 버전확인을 진행하고 CUDA 설치를 진행한다. CUDA 설치 사이트로 들어가 

자신의 GPU성능에 맞는 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

CUDA 11.4 버전을 예시로 들어 설명을 진행 하겠다. 

버전에 맞는 CUDA 설치 화면에 들어가면 다음과 같이 설정을 해준다. 

Target Platform

이렇게 설정을 진행하면 아래에 설치 코드가 나오게 된다. 

이코드를 터미널에 차례로 입력을 진행하면 된다.

1번째는 다운로드를 받는 코드이고 2번째는 다운로드 위치로 이동후 명령어를 입력하면된다. 

$ wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
$ sudo sh cuda_11.4.0_470.42.01_linux.run

 

설치를 진행한후 ~/.bashrc를 수정한다. 

sudo gedit ~/.bashrc

 

gedit 창이 켜지면 맨 아래의 두줄을 추가해준다. 이때 cuda-11.4 부분은 본인이 설치한 CUDA 버전을 따르면 된다.  

export PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

마지막으로 재부팅을 진행한다. 

CUDA 설치를 확인 하는 명령어는 아래와 같다. 

$ nvcc -V

CUDA 설치 확인


Reference 

https://www.youtube.com/watch?v=mmp-hay0eeM&t=8s


정확한 정보 전달보단 공부 겸 기록에 초점을 둔 글입니다. 틀린 내용이 있을 수 있습니다.
틀린 내용이나 다른 문제가 있으면 댓글 남겨주시거나 또는 이메일로 보내주시면

감사하겠습니다.