Skip to main content

How to install Nvidia Cuda Toolkit on Kali Linux

Following the official documentation for installing Nvidia driver on Kali 2.0 didn’t work for me. I installed nvidia-kernel-dkms, disabled nouveau driver, and rebooted. Then I had an error saying Something went wrong.. and presented with only a logout button. I was unable to login to the graphical interface. So I dug every bit of information in the internet and finally installed NVIDIA driver (340.98) on Kali (kernel 4.0.0).

Step 1: Download the driver for your GPU.
To know which driver to download, run lspci | grep -E "VGA|3D" command. It will show the GPU you currently have. Mine is GeForce 9800GTX. Then look for the appropriate driver for your GPU at Nvidia website. Here are the archives for 64 bit and 32 bit system. After downloading the driver, place it somewhere in your home folder – we will be needing it later. Make it executable chmod +x ~/Downloads/NVIDIAxxxx.run.

Step 2: Install Kali linux Kernel headers

apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
apt-get install -y linux-headers-$(uname -r)

**If you have installed nvidia-kernel-dkms earlier, remove it and all nvidia packages by apt-get remove nvidia* –purge.

Step 3: Stop X server

We need to stop the X server so we can run the Nvidia installer. Kali2.0 uses gdm by default. You can stop the X server by stopping gdm systemctl stop gdm. Another way is to hit Ctrl+Alt+Backspace. You can also try the methods suggested here in case previous methods don’t work.

Step 4: Install Nvidia Driver
Now, cd into the directory where the installer is located. Then run the installer ./NVIDIAxxxx.run -a. Just accept whatever the installer asks. For 64 bit systems, you might encounter a question about 32bit libs, just ignore it.

ATTENTION: When normal installation not works, try the following and follow instructions:

apt-get install nvidia-legacy-check

Todo: add screenshot here.

Find the right package name:

apt-cache search nvidia-*

Install the driver:

apt-get install nvidia-legacy-340xx-driver

Als de installer klaar is, herstart je je machine.

reboot

Als het systeem is herstart, zie je een NVIDIA splash screen, wat aangeeft dat de drivers correct zijn geïnstalleerd, alhoewel, dit niet altijd het geval is. Om er zeker van te zijn, dat de drivers correct werken, geef het volgende commando:


root@kali:~# glxinfo | grep -i "direct rendering"
direct rendering: Yes

After the installation completes, we need to disable the nouveau driver and configure the X server.

Step 5: Configure X server (OPTIONAL)
Then, configure xorg.conf. You will need to know the PCI address of the NVIDIA card, which you can find by issuing lspci | grep -E "VGA|3D". The PCI address is the first 7 characters of the line that mentions NVIDIA. It will look something like 01:00.0. In the xorg.conf, you will need to format it as #:#:#; e.g. 01:00.0 would be formatted as 1:0:0.

In my case, the bus id for my GPU was 04:00.0.

Edit/create the file /etc/X11/xorg.conf and add the following lines:


Section "Module"
    Load "modesetting"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "4:0:0"
    Option "AllowEmptyInitialConfiguration"
EndSection

Then create a file /usr/share/gdm/greeter/autostart/display_setup.desktop and paste the following lines:


[Desktop Entry]
Type=Application
Name=Display setup
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"
NoDisplay=true
X-GNOME-AutoRestart=true

Reboot and you should be good to go.

Step 6: Install Nvidia Cuda Toolkit

First stop gdm. We need to stop the X server so we can run the Nvidia Cuda Toolkit installer. Kali 2.0 uses gdm by default. You can stop the X server by stopping gdm systemctl stop gdm. Another way is to hit Ctrl+Alt+Backspace.

Installing Prerequisites

If your system does not include necessary dependencies, you might encounter following error when installing CUDA toolkit.


Missing recommended library: libGLU.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so

You need to install additional libraries which installs above dependencies as follows:

sudo apt-get install libglu1-mesa libxi-dev libxmu-dev
apt-get install nvidia-cuda-toolkit

Check if your GPU is ready for Cuda:
http://www.geforce.com/hardware/technology/cuda/supported-gpus

Legacy GPU’s:
https://stackoverflow.com/questions/29241538/which-cuda-toolkit-version-for-older-nvidia-driver
https://developer.nvidia.com/cuda-legacy-gpus

https://devtalk.nvidia.com/default/topic/796269/cuda-setup-and-installation/most-recent-cuda-version-for-a-legacy-card/

For legacy GPU’s, install Nvidia Cuda Toolkit v6.5:
https://developer.nvidia.com/cuda-toolkit-archive

chmod +x cuda_6.5.14_linux_64.run
./cuda_6.5.14_linux_64.run

If you get the following error:
Unsupported compiler 4... Use –override to override this check

it says that your gcc compiler is incompatible with the installation. To prevent this error, you need to change the installation step as,
sudo ./cuda_6.5.14_linux_64.run --override compiler

You can then accept the EULA, and at the next step, do not install nvidia accellerated graphics driver(select no to when asking to install the driver), since we already have installed a proprietery driver.

https://devtalk.nvidia.com/default/topic/968656/cuda-8-0-on-debian/
https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations

apt-get install libnvidia-legacy-240xx-cudal

At the end of the installation copy the file xorg.conf first edited in the folder /etc/X11/

cp xorg.conf /etc/X11/

Reboot system

reboot

OLD STUFF:

Step 2: Install Cuda dependencies

aptitude install libpcap-dev python2.7-dev libcr-dev mpich2 mpich2-doc libglu1-mesa-dev libglu1-mesa libglui-dev libxmu-dev libxi-dev build-essential binutils gcc-4.6 g++-4.6 freeglut3-dev libx11-dev libgl1-mesa-glx

Step 4: Give permissions to the script running nvidia (valid command if discharged in the root directory)

chmod 755 cuda_5.5.22_linux_32.run

Step 5: Blacklist Nouveau Driver update grub and reboot system

sed 's/quiet/quiet nouveau.modeset=0/g' -i /etc/default/grub
update-grub
reboot

step 6: Edit file xorg.conf (it is for nvidia geforce gt 630)

Open Leafpad and copy and paste this, where necessary re-edit according to your screen, or graphics card:

Section "ServerLayout" Identifier "Layout0" Screen 0 "Screen0" 0 0 InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Mouse0" "CorePointer" EndSection Section "Files" EndSection Section "InputDevice" # generated from default Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/psaux" Option "Emulate3Buttons" "yes" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" # generated from default Identifier "Keyboard0" Driver "kbd" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Unknown" ModelName "CRT-1" HorizSync 30.0 - 80.0 #if you need to change the parameters for your main domain display VertRefresh 55.0 - 75.0 #if you need to change the parameters for your main domain display Option "DPMS" EndSection Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "GeForce GT 630" #if you need to change the parameters for your card EndSection Section "Module" Load "glx" EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Depth 24 EndSubSection EndSection

Save the file in the root folder with name calling xorg.conf

Step 7: Install Cuda

First stop gdm

service gdm3 stop

Second press ctrl+alt+f1 on keyboard and re-login in the system

Third run nvidia script

sh cuda_5.5.22_linux_32.run

Accept the EULA, accept the installation etc and install in the default folder

Fourth at the end of the installation copy the file xorg.conf first edited in the folder etc/X11/

cp xorg.conf /etc/X11/

Reboot system

reboot

Step 8. setting Cuda for install Pyrit

Create symbolic links in for the correct installation of Pyrit

First create symbolic link Cuda folders in /opt

ln -s /usr/local/cuda /opt

Second create symbolic link to nvcc /usr/bin

ln -s /usr/local/cuda-5.5/bin/nvcc /usr/bin/

Try if it works nvcc

nvcc -V

Step 9 Download Pyrit and Cpyrit

wget http://pyrit.googlecode.com/files/pyrit-0.4.0.tar.gz
wget http://pyrit.googlecode.com/files/cpyrit-cuda-0.4.0.tar.gz

Step 10: Extract, and install Pyrit and Cpyrit

tar -xvzf pyrit-0.4.0.tar.gz
tar -xvzf cpyrit-cuda-0.4.0.tar.gz
cd /root/cpyrit-cuda-0.4.0
python setup.py build
python setup.py install
cd /root/pyrit-0.4.0
python setup.py build
python setup.py install

Try if it works Pyrit

pyrit list_cores
pyrit benchmark

[:en]Step 1. Install Kali linux Kernel headers

aptitude update && aptitude install -y linux-headers-$(uname -r)

Step 2. Install Cuda dependencies

aptitude install libpcap-dev python2.7-dev libcr-dev mpich2 mpich2-doc libglu1-mesa-dev libglu1-mesa libglui-dev libxmu-dev libxi-dev build-essential binutils gcc-4.6 g++-4.6 freeglut3-dev libx11-dev libgl1-mesa-glx

 

Step 3. Download last Nvidia Cuda driver whit official site here

https://developer.nvidia.com/cuda-downloads

I preferred to download drivers for Ubuntu 10.04 64bit(i have kali 64 bit)

 

Step.4 Give permissions to the script running nvidia (valid command if discharged in the root directory)

 

chmod 755 cuda_5.5.22_linux_32.run

 

Step 5. Blacklist Nouveau Driver update grub and reboot system

 

sed 's/quiet/quiet nouveau.modeset=0/g' -i /etc/default/grub

 

update-grub

 

reboot

 

step 6. edit file xorg.conf (it is for nvidia geforce gt 630)

 

open leafpad and copy and paste this,where necessary re-edit according to your screen, or graphics card

 

Section "ServerLayout" Identifier "Layout0" Screen 0 "Screen0" 0 0 InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Mouse0" "CorePointer" EndSection Section "Files" EndSection Section "InputDevice" # generated from default Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/psaux" Option "Emulate3Buttons" "yes" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" # generated from default Identifier "Keyboard0" Driver "kbd" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Unknown" ModelName "CRT-1" HorizSync 30.0 - 80.0 #if you need to change the parameters for your main domain display VertRefresh 55.0 - 75.0 #if you need to change the parameters for your main domain display Option "DPMS" EndSection Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "GeForce GT 630" #if you need to change the parameters for your card EndSection Section "Module" Load "glx" EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Depth 24 EndSubSection EndSection

 

Save the file in the root folder with name calling xorg.conf

 

Step 7. Install cuda

 

first stop gdm

 

service gdm3 stop

 

second press ctrl+alt+f1 on keyboard and re-login in the system

 

third run nvidia script

 

sh cuda_5.5.22_linux_32.run

 

accept the eula accept the installation etc and install in the default folder

 

fourth at the end of the installation copy the file xorg.conf first edited in the folder etc/X11/

 

cp xorg.conf /etc/X11/

 

reboot system

 

reboot

Step 8. setting Cuda for install Pyrit

 

Create symbolic links in for the correct installation of Pyrit

 

First create symbolic link Cuda folders in /opt

 

ln -s /usr/local/cuda /opt

 

Second create symbolic link to nvcc /usr/bin

ln -s /usr/local/cuda-5.5/bin/nvcc /usr/bin/

Try if it works nvcc

nvcc -V

Step 9. Download Pyrit and Cpyrit

wget http://pyrit.googlecode.com/files/pyrit-0.4.0.tar.gz

wget http://pyrit.googlecode.com/files/cpyrit-cuda-0.4.0.tar.gz

Step 10. Extract, and install Pyrit and Cpyrit

tar -xvzf pyrit-0.4.0.tar.gz

tar -xvzf cpyrit-cuda-0.4.0.tar.gz

cd /root/cpyrit-cuda-0.4.0

python setup.py build

python setup.py install

cd /root/pyrit-0.4.0

python setup.py build

python setup.py install

Try if it works Pyrit

pyrit list_cores

pyrit benchmark

Reacties (1)

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *