Thursday, February 5, 2015

How to install Nvidia driver and cuda in linux(centos 6.5)

If we are planning to install cuda in linux, The requirement are:
1)      Installation of nvidia driver
2)      Installation of cuda toolkit



Installation  of nvidia driver:
By default linux system doesnot have nvidia driver installed with it. In centos it has Nouveau driver installed. Thus first we need to install Nvidia driver. Installation of Nvidia driver requires some useful task.

The important thing we need to take care while installation of nvidia driver is that we need to have same version of kernel and kernel-devel of the particular linux installed.

First let’s check the kernel using command unname-r it gives the version of kenel
Second we need to check the kernel-devel version with command  (in centos) rpm –q  kernel-devel



If we have same kernel and kernel-devel we can directly proceed forward to install nvidia driver otherwise we need to update our kernel, kernel-devel and kernel-headers to the same version before we proceed to install nvidia driver.

Steps of updating to the requirements(same version)  in centos are
1)      yum groupinstall “Development Tools”
2)      yum install kenel-devel kernel-headers dkms
3)      yum install kernel
4)      mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
5)      dracut -v /boot/initramfs-$(uname -r).img $(uname -r)
6)       reboot
then the new kernel will be seen during reboot , open the new kernel , now we need to blacklist nouveau in /etc/modprobe.d/blacklist.conf file. For this follow the steps
1)    Enter the command root mode
gedit  /etc/modeprobe.d/blacklist.conf and add the line blacklist nouveau in this file.
then download the nvidia driver , place it in appropriate place
enter init 3 in command, black screen appears , enter user name , password and log in as root user , move to the nvidia driver file , add permission to execute the file using
chmod  +x filename
and run the file as ./filename


this install the driver and finally enter init 5 to return to normal linux

finally now cuda file can be downloaded and installed using

./cuda_your_version.run

now test the cuda is installed or not by typing nvcc . If nvcc is recognized then cuda is installed successfully.

1 comment: