Install Cuda Toolkit — Cuda Driver
The CUDA Driver acts as a bridge between the operating system and the GPU, enabling communication with the hardware. Without it, the CUDA Toolkit, which provides software tools for GPU programming, cannot function properly. So, before installing the CUDA Toolkit, it's essential to install the CUDA Driver to ensure proper GPU utilization.
If you don't know the difference between them, I have explained in here
Install Cuda Driver
To begin, it's important to verify that your NVIDIA driver is compatible with your computer.
For example: my computer is Geforce MX570 - Ubuntu 22.04
Now I know that my suitable Nvidia Driver version is: 545.29.02
Let's open Software & Updates and install Nvidia Driver. Notice that install driver metapackage
After installing, click restart
You have successfully installed the CUDA Driver. You can verify this by open terminal and run this command
$nvidia-smi
You'll notice a recommendation for the CUDA Toolkit version
Install Cuda Toolkit
Now, you need to find the appropriate CUDA Toolkit to download in this link
For example: I need to isntall Cuda Toolkit version: 12.3
Follow the Installation Instructions
When done, run these commands to add your path
$nano /home/$USER/.bashrc
Then scroll until the end and add these ( replace cuda-12.3 into your version )
export PATH="/usr/local/cuda-12.3/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH"
Then:
Ctrl + o : save
Enter : accept changes
Ctrl + x : close editor
You have successfully installed the CUDA Toolkit. You can verify this by open terminal and run this command:
$nvcc -V