Personal Memo/Envirement

CUDA Reinstall

soel0256 2023. 7. 4. 15:34

ncidia-smi :

Displays the top cuda version that is compatible with the currently installed nvidia-driver, not the cuda version of the real server EditVoting Translation 

nvidia-smi

nvcc- --version : Check the actual current version
Current CUDA version shown below

# CUDA version check
nvcc --version

Current CUDA version 9.1

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Delete an existing installed CUDA

# Sequential execution

sudo apt-get purge nvidia*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

Add Key

# Sequential execution

sudo wget -O /etc/apt/preferences.d/cuda-repository-pin-600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"

 

Determind which driver to install

# Check the list of NVidia drivers that can be installed

ubuntu-drivers devices

A list of installable nvidia driver devices is output

You can check the CUDA version you want to install and the list of nvidia drivers accordingly from the link below

Link : https://docs.nvidia.com/deploy/cuda-compatibility/index.html#binary-compatibility__table-toolkit-driver

Installing the NVIDIA DRiver

For CUDA 11.3 installation, nvidia driver was installed as nvidia-driver-470

# Sequential execution

sudo apt-get install nvidia-driver-470
sudo apt-get install dkms nvidia-modprobe
sudo apt-get update
sudo apt-get upgrade
 
When the installation is complete, restart the server
 
# reboot

sudo reboot now

-----------------------------------------------------------------------------------------------------------------------------------------------------------------Confirm Installation

 
Install CUDA Toolkit 11.3 Downloads
 
The base installer is available for download below
# Sequential execution

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/11.3.0/local_installers/cuda-repo-ubuntu1804-11-3-local_11.3.0-465.19.01-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu1804-11-3-local_11.3.0-465.19.01-1_amd64.deb

sudo apt-key add /var/cuda-repo-ubuntu1804-11-3-local/7fa2af80.pub

sudo apt-get update

sudo apt-get -y install cuda

(First time installing on a server only) Installing gcc-related

# Sequential execution

sudo apt update 
sudo apt install build-essential 
sudo apt-get install manpages-dev

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Environmental variable registration

In the CUDA list that appears, check the CUDA version folder that you want to install

ls /usr/local | grep cuda

 

# If the cuda-11.3 folder is the target, you can register the environment variable with the following command.

# If the CUDA version that you want to install replaces the version and writes it instead of 11.3, you can run it.
 
# Sequential execution

sudo sh -c "echo 'export PATH=$PATH:/usr/local/cuda-11.8/bin'>> /etc/profile"

sudo sh -c "echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.8/lib64'>> /etc/profile"

sudo sh -c "echo 'export CUDARDIR=/usr/local/cuda-11.8'>> /etc/profile"

source /etc/profile
 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

 

check "nvcc --version"

 

If an error occurs

sudo apt install nvidia-cuda-toolkit

 

 

refer from : https://teddylee777.github.io/linux/ubuntu2004-cuda-update/#cuda-toolkit-118-downloads