This post is a simple, quick and easy “how to” install Nvidia Tesla drivers and CUDA 5 on Linux Ubuntu Server 11.10. CUDA is a parallel computing architecture which enables dramatic increases of computing performances by harnessing the power of the graphic processing unit (GPU). This guide covers the installation of the Nvidia Tesla K20m drivers as well as the installation of the CUDA and SDK toolkit on Ubuntu.
System Requirements :
Before beginning this tutorial you need to make sure that you have CUDA enabled hardware ( CUDA-capable GPU).
The list of all the CUDA capable devices can be found here.
To find out the type of Nvidia Graphic card your computer posses use the following command in a terminal :
1 |
lspci | grep -i |
Driver Installation :
Before installing the drivers, it is important to check that you have a supported version of Linux, to check so use the following command in your terminal :
1 |
uname -m && cat /etc/*release |
A similar output should appear on your screen :
1 2 3 4 5 6 |
$ uname -m && cat /etc/*release x86_64 DISTRIB_ID=Ubuntu DISTRIB_RELEASE=11.10 DISTRIB_CODENAME=oneiric DISTRIB_DESCRIPTION="Ubuntu 11.10" |
As you can see “x86_64” indicates that you are running a 64 bit system, while the “ DISTRIB_RELEASE” field indicates your version of the operating system. In this case Linux Ubuntu 11.10 which is a supported version of Linux for CUDA5.
Following these information, download the drivers of your card via the nvidia’s driver website here.
If you have installed Ubuntu 11.10 Server you should not have any graphical user interface (GUI), you can thus download the drivers by using the command “wget url_of_the_drivers.run” .
Once the driver downloaded, install the following libraries and packages required by CUDA5 :
1 |
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev |
Then black list the un-required modules of the operating system.
1 |
sudo vim /etc/modprobe.d/blacklist.conf |
The previous command opened the blacklist.conf file, press the “i” key, to edit the file and add the following lines to the file :
1 2 3 4 5 6 7 8 |
#blacklist Nvidia blacklist amd76x_edac blacklist vga16fb blacklist nouveau blacklist rivafb blacklist nvidiafb blacklist rivatv |
To save, press the “esc” key and enter “:wq” to quit.
If you are using a graphical user interface before installing the drivers, please follow these steps :
- In the terminal write the following command to change the system run level :
1 |
sudo init 3 |
- Disable the graphical user interface :
1 |
sudo service lightdm stop |
We can now proceed to the installations of the drivers. The first step is to change the rights of the drives to be able to execute the drives, to do so write the following command in the terminal :
1 |
sudo chmod u+x NAME_OF_THE_DRIVER.run |
We can now execute the drivers :
1 |
sudo ./NAME_OF_THE_DRIVERS.run |
Once the drivers installed you can now download CUDA5 (here) by using the command wget in my case it will look like
1 |
wget http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_linux_64_ubuntu11.10-1.run |
you can now reboot your system.
Cuda Toolkit Installation :
To install the drivers, we will have to follow the same procedure has before, and give the rights to the cuda5 file to be executed :
1 |
sudo chmod u+x cuda_5.0.35_linux_64_ubuntu11.10-1.run |
and we can now install CUDA5
1 |
sudo ./cuda_5.0.35_linux_64_ubuntu11.10-1.run |
Once Installed we should now define the environment variables, to proceed so, open the following file : ~/.bash_profile via the following command :
1 |
sudo vim ~/.bash_profile |
(use the “i” key to edit, “esc” + “:wq” to save)
If you use a 32 bit system add the following lines :
1 2 |
export PATH=/usr/local/cuda-5.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib:$LD_LIBRARY_PATH |
If you use a 64 bit system add the following lines :
1 2 |
export PATH=/usr/local/cuda-5.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib:/usr/local/cuda-5.0/lib64:$LD_LIBRARY_PATH |
Once done, you can now restart the computer, and use CUDA via the GUI. If you are not using a GUI, read CUDA Error 38. However if you use a GUI system, you can now restart your system and you should now be able to use CUDA5 on your Linux Machine.
CUDA Error 38:
If you happen to see this error while executing a CUDA example, you should edit the following file /etc/rc.local via this command :
1 |
sudo vim /etc/rc.local |
and add the following line :
1 |
/home/noktec/NvidiaStartup.sh |
Then create a file called NvidiaStartup.sh in /home/(your user name) via the following command :
1 |
vim NvidiaStartup.sh |
and add the following lines :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/bin/bash /sbin/modprobe nvidia if [ "$?" -eq 0 ]; then # Count the number of NVIDIA controllers found. NVDEVS=`lspci | grep -i NVIDIA` N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l` NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l` N=`expr $N3D + $NVGA - 1` for i in `seq 0 $N`; do mknod -m 666 /dev/nvidia$i c 195 $i done mknod -m 666 /dev/nvidiactl c 195 255 else exit 1 fi |
You can now restart your computer and run your CUDA examples.
CUDA Error 10 :
If you face a CUDA Error 10, you might have plugged your card in the wrong way ! We faced this error after having received our Supermicro computer, and discovered after multiple research that the cables plugged to our card were not plugged correctly, after reading documentation of the Tesla K20m card (available here) we noticed that the supplier had plugged two 6 pins connectors into the card instead of one 8pin and one 6 pin connector, once the 8 and 6 pin connectors plugged correctly our CUDA Error 10 disappeared.
This problem was discovered by using the following command :
1 |
nvidia-smi -q |
This might help you debug your problem. In this case “-q” should list the available GPUs on your system.
I hope this helped and you are now ready to use CUDA on Linux.
Post a Comment