Time Server
Post by
Author Syukra

Published on Dec 14, 2024

Last updated on Apr 11, 2025

Estimated reading time: 5 minute

How to Install Nvidia Cuda on Kali Linux

Install Nvidia Cuda On Kali Linux

NVIDIA CUDA is a parallel computing platform that enables graphics processing using NVIDIA GPUs. With CUDA, you can accelerate various heavy-duty tasks such as image processing, machine learning, and deep learning. In this article, we will discuss how to install NVIDIA CUDA on Kali Linux. Here are the steps you can follow to ensure a smooth installation process.

Preparation Before Installation

  1. Check NVIDIA GPU Compatibility: Before installing CUDA, make sure that your GPU is compatible with CUDA. You can check the GPU compatibility list on NVIDIA’s official website.
  2. Update Kali Linux System: Make sure your Kali Linux system is updated to the latest version. You can do this by running the command:
sudo apt update && sudo apt upgrade -y
  1. Installing Dependencies: Before downloading and installing CUDA, there are some dependencies that need to be installed for a smooth installation process. Run this command in terminal:
sudo apt install build-essential dkms -y

Step 1: Installing NVIDIA Drivers

CUDA only works if NVIDIA drivers are installed correctly. Make sure you install the appropriate NVIDIA drivers for your GPU.

  1. Adding Non-Free Repositories: Since NVIDIA drivers are non-free, add the non-free repositories to your Kali Linux system by editing the sources.list file. Run:
sudo nano /etc/apt/sources.list

Add the following lines inside the file:

deb http://http.kali.org/kali kali-rolling main non-free contrib

Save and close the file by pressing CTRL + X, Y, then Enter.

  1. Update Package List: Run the following command to update the package list:
sudo apt update
  1. Install NVIDIA Driver: Once the non-free repository is added, install the NVIDIA driver with the command:
sudo apt install -y nvidia-driver -y
  1. Restart System: Once the driver is installed, restart the system by running:
sudo reboot
  1. Verify Driver Installation: After restarting, you can verify the driver installation by running the following command in the terminal:
nvidia-smi

If the driver is installed correctly, you will see information about your NVIDIA GPU.

Step 2: Downloading CUDA Toolkit

Once the driver is installed correctly, the next step is to download CUDA Toolkit from NVIDIA’s official website.

  1. Access NVIDIA Official Website: Open CUDA Toolkit website in your browser.
  2. Select CUDA Version: Select the CUDA version that is compatible with your driver and GPU. Also make sure to select a version that supports Linux operating systems and x86_64 architecture.
  3. Download CUDA Installer: Choose the .run or deb (network) based download method according to your needs.

Step 3: Installing CUDA Toolkit

Next, we will install CUDA Toolkit. There are two ways to install CUDA on Kali Linux: via the .run installer or the .deb file.

Using the .run Installer File

  1. Navigate to Download Folder: Open a terminal and navigate to the folder where you saved the CUDA .run installer.
cd /path/to/download
  1. Change File Permissions: Make the installer executable with the command:
chmod +x cuda_<version>_linux.run
  1. Run the Installer: Once the file permissions have been changed, run the installer with the following command:
sudo ./cuda_<version>_linux.run
  1. Follow the Installation Instructions: When the installation begins, you will be presented with several options. Choose according to your needs, and be sure to select the option to install the NVIDIA drivers (if not already installed) and the CUDA Toolkit.

Using the .deb Installer File

  1. Add the CUDA Repository: Open a terminal and add the CUDA repository by downloading and installing the .deb file:
sudo dpkg -i cuda-repo-<distro>_<version>_amd64.deb
  1. Update Package Lists: Run the following command to update the package lists:
sudo apt update
  1. Install CUDA: Once the repository is updated, install CUDA with the command:
sudo apt install -y cuda
  1. Add Path to Bash Profile: To make CUDA accessible from the terminal, add the CUDA directory to the PATH. Open the .bashrc file:
nano ~/.bashrc

Add the following lines to the bottom of the file:

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Save and close the file.

  1. Activate Path Changes: Apply the configuration changes by running:
source ~/.bashrc

Step 4: Verify CUDA Installation

Once CUDA is installed, the next step is to verify its installation. You can verify that CUDA is installed correctly by running the following command:

nvcc -V

If CUDA is installed correctly, you should see output indicating the CUDA version.

Step 5: Testing CUDA

To make sure CUDA is working properly, you can run the CUDA sample project provided by NVIDIA. You can copy the sample project by running:

cuda-install-samples-<version>.sh ~/

This will copy the sample project to your home directory. You can then compile and run the sample to make sure CUDA is working properly.

  1. Go to the Sample Directory:
cd ~/NVIDIA_CUDA-<version>/samples/1_Utilities/deviceQuery
  1. Compile Sample:
make
  1. Run Sample:
./deviceQuery

If CUDA is installed correctly, you will see your GPU details, such as the number of multiprocessors and memory capacity, in the output. This indicates that your GPU is ready to be used with CUDA.

By following the steps above, you have successfully installed NVIDIA CUDA on Kali Linux. CUDA is ready to be used in various parallel computing applications, deep learning, or application development that requires high processing power.

That’s all the articles from Admin, hopefully useful… Thank you for stopping by…

Tag: #Tutorial
Share Article

Follow My Social Media