How to install NVIDIA CUDA on Debian 10

CUDA® is a parallel computing platform and programming model developed by NVIDIA for general computing on graphical processing units (GPUs). With CUDA, developers are able to dramatically speed up computing applications by harnessing the power of GPUs.

We will install NVIDIA CUDA on a Debian 10 server. Run the following commands as user root. If you are logged in with sudo user, you can run the command “sudo su” to become user root.

Add NVIDIA repository

apt install software-properties-common -y
add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/ /"
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/7fa2af80.pub

Enable the contrib repository

add-apt-repository contrib

Update the apt cache

apt-get --allow-releaseinfo-change update

Install cuda

apt-get -y install cuda

To find Nvidia driver version, you can run the command cat /proc/driver/nvidia/version

root@sok-1:~# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  470.103.01  Thu Jan  6 12:10:04 UTC 2022
GCC version:  gcc version 8.3.0 (Debian 8.3.0-6) 
root@sok-1:~#

cuda installed in folder /usr/local/cuda-11.4/bin/, to find version, run

root@sok-1:~# /usr/local/cuda-11.4/bin/nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_Oct_11_21:27:02_PDT_2021
Cuda compilation tools, release 11.4, V11.4.152
Build cuda_11.4.r11.4/compiler.30521435_0
root@sok-1:~# 

Add the folder to PATH, edit the file

vi ~/.bashrc

Add following

if [ -d "/usr/local/cuda-11.4/bin/" ]; then
    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}}
fi

Save and exit the file. Reload .bashrc with

source ~/.bashrc

You can find more info on NVIDIA driver with the command

nvidia-smi

NVIDIA CUDA command line

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *