우분투에 CUDA 12.3 설치

우분투에 CUDA 12.3 설치

GPU가 있는지 확인

1
lspci | grep -i nvidia

기존의 설치된것 삭제

1
2
3
4
5
6
7

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

system update

1
2
3
4

sudo apt-get update
sudo apt-get upgrade

install other import packages

1
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

PPA repository driver 추가

1
2
3
4

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

install nvidia driver with dependencies

1
2
3
4
5
6
7
8
9
10

sudo apt install libnvidia-common-545
sudo apt install libnvidia-gl-545
sudo apt install nvidia-driver-545

sudo wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"

1
nvidia-smi

system update

1
2
3
4

sudo apt-get update
sudo apt-get upgrade

installing CUDA-12.1

1
sudo apt install cuda-12-1

아래의 오류가 나면 처리 방법

1
2
3
The following packages have unmet dependencies:
libnvidia-extra-525 : Conflicts: libnvidia-extra
libnvidia-extra-535 : Conflicts: libnvidia-extra
1
2
sudo apt full-upgrade

paths 설정

1
2
3
4
5
6

echo 'export PATH=/usr/local/cuda-12.1/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

1
2
3
sudo update-alternatives --display cuda

sudo update-alternatives --config cuda

cuda 버전이 불일치 함?

1
2
3
nvcc -V

nvidia-smi

문제 없다고 함???

UEFI Secure Boot를 비활성화 해야 함

아래는 확인 커멘드

1
sudo mokutil --sb-state 

참조