How to Install and Use CUDA on Debian 11 (Step-by-Step)

If you’re working with applications that need a lot a computing power, like machine learning, AI, or video processing, CUDA can help speed things up by using the power of your NVIDIA GPU, in this guide we will walk you through How to Install and Use CUDA on Debian 11, don’t worry if you are new o this, just follow the steps, and you’ll have to CUDA ready to go in no time.
Steps to Install NVIDIA Graphics Driver
To get started with installing the NVIDIA graphics driver, you’ll first need to make sure your system is ready, let’s walk through each step to get your graphics and card running smoothly.
Prerequisites
1. A Linux VPS Server or a Local system with Debian 11 OS
2. CUDA Toolkit from NVIDIA, which is a software platform for GPU computing.
3. An NVIDIA graphics card that supports CUDA (check if your GPU is listed as CUDA-enabled on NVIDIA’s official site).
Step 1: Update Your Package Source
If your computer has an NVIDIA graphics card, you can install the NVIDIA Graphics Driver to improve graphics performance, After installation, restart the computer to load the default general driver into the new NVIDIA driver.
vi /etc/apt/sources.list
Step 2: Add Required Repositories
Then, you should add [non-free] to the main line, also, if contrib is not set, add it, too, as the following commands:
deb http://deb.debian.org/debian/ bullseye main contrib non-free
Step 3: Install NVIDIA Driver
If your card is before the GeForce 600 series or similar products, install [nvidia-legacy-390xx-driver] using the following command:
apt update
apt -y install nvidia-driver firmware-misc-nonfree
Step 4: Disable the Nouveau Driver
Disable the default Nouveau Driver using the following command:
cat /etc/modprobe.d/nvidia-blacklists-nouveau.conf
update-initramfs -u
Step 5: Reboot the System
Finally, you can reboot the system using the following command:
reboot
Step 6: Confirm Installation
Please confirm the installation to view the status of the graphics card. Using the following command:
nvidia-smi
How to Install CUDA on Debian 11
Before starting How to Install CUDA on Debian 11, it is necessary to install NVIDIA Graphics Driver by running the following command. Therefore, it is necessary to perform the following steps in order.
By default, you add the words [contrib non-free] to the following command in the APT source, as in the previous step:
apt -y install nvidia-cuda-toolkit nvidia-cuda-dev
nvcc --version
In the next step, you should verify the installation with a common user to run a sample program using the following command:
git clone https://github.com/zchee/cuda-sample.git
cd ./cuda-sample/1_Utilities/deviceQuery
/cuda-sample/1_Utilities/deviceQuery$ vi Makefile
Now you should change line 37 as follows:
CUDA_PATH?=/usr
You should also change line 192 as follows:
SMS ?= 70
Compile the device query sample using the following command:
/cuda-sample/1_Utilities/deviceQuery$ make
Run the deviceQuery sample using the following command:
/cuda-sample/1_Utilities/deviceQuery$ ./deviceQuery
It should be noted that you should try to run a bandwidth test sample using the following command:
cd ~/cuda-sample/1_Utilities/bandwidthTest
/cuda-sample/1_Utilities/bandwidthTest$ vi Makefile
Again you need to change line 37 as follows:
CUDA_PATH?=/usr
change line 192 as follows:
SMS ?= 70
/cuda-sample/1_Utilities/bandwidthTest$ make /cuda-sample/1_Utilities/bandwidthTest$ ./bandwidthTest
Conclusion
CUDA helps your NVIDIA graphics card make heavy tasks like AI, machine learning, and video work faster, This guide shows you how to install and use CUDA on Debian 11 step by step, even if you’re new, just follow the steps and you will have everything set up easily, after installing the driver and CUDA, and testing with sample programs, your system will be ready to use CUDA to speed up your work, now you can start using your GPU for faster computing!
You might like it
Ubuntu Tutorials
How to Enable Coolbits on Ubuntu 22.04
Windows Tutorials
How to Connect to VPS on Windows 10
How to Install Hadoop on Debian 10 [Complete]