CUDA is A great Parallel computing set of tools by nvidia to facilitate Parallel programing on GPGPUs (General Purpose Graphics Processing Unit). Which is basically the door to high performance and parallel computing. In this tutorial, I'll explain to you how to install CUDA and linux and get started with developing.
Download the Developer's driver & CUDA toolkit.
1. Download the latest nvidia developers' driver from here (32 bit) or here (64 bit).
2. Download the latest CUDA toolkit from here (32 bit) or here (64 bit).
2. Download the latest CUDA toolkit from here (32 bit) or here (64 bit).
Clean up all Old nvidia drivers that might conflict.
3. Remove any pre-installed nvidia drivers on your system so, type the following command:
sudo apt-get purge nvidia-*
4. blacklist all the nvidia drivers on the ubuntu repositories from ever installing / Updating:
sudo nano /etc/modprobe.d/nvidia-graphics-drivers.conf
Then insert the following lines:
blacklist vga16fb
blacklist nouveau
blacklist lbm-nouveau
blacklist nvidia-173
blacklist nvidia-96
blacklist nvidia-current
blacklist nvidiafb
And finally hit ctrl + o followed by Enter.
blacklist vga16fb
blacklist nouveau
blacklist lbm-nouveau
blacklist nvidia-173
blacklist nvidia-96
blacklist nvidia-current
blacklist nvidiafb
And finally hit ctrl + o followed by Enter.
Make sure you have the necessary required packages:
5. Make sure you have the gcc compiler installed:
sudo apt-get install gcc
Installing the Driver:
6. Exit the Ubuntu GUI by typing this command:
sudo /etc/init.d/gdm stop
7. Run the driver package you downloaded in step 1 by typing the following:
cd /my_directory sudo ./package_name.run
** Where "my_directory" is the folder where you downloaded the nvidia developers' driver and "package_name" is the name of the downloaded file. Hint: If the second command fails try "sudo bash package_name.run" instead.
- Some Fancy Terminal Installation interface will appear. But I'm pretty sure u'll make ur way through ;)
8. Verify that you have successfully installed the driver:
- Some Fancy Terminal Installation interface will appear. But I'm pretty sure u'll make ur way through ;)
8. Verify that you have successfully installed the driver:
cat /proc/driver/nvidia/version
9. Restart the Ubuntu GUI Environment =)
sudo /etc/init.d/gdm start
Install the CUDA Toolkit:
10. Install The CUDA toolkit you downloaded in step 2:
cd /my_directory sudo ./cuda_toolkit.run
** Where "my_directory" is the folder where you downloaded the cuda toolkit and "cuda_toolkit" is the name of the cuda toolkit file you downloaded into that folder. Hint: If the second command fails try "sudo bash cuda_toolkit.run" instead.
- PLEASE DO NOT MESS WITH THE INSTALLATION PATH UNLESS YOU KNOW WHAT U ARE DOING!
- PLEASE DO NOT MESS WITH THE INSTALLATION PATH UNLESS YOU KNOW WHAT U ARE DOING!
11. Set and save CUDA environment path:
sudo gedit /etc/bash.bashrc
Add the following two lines to the end of the file then save & close:
# Set nvcc Compiler path export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH
12. To Verify that it all went well, the following command in your terminal should show an output:
nvcc --version
CUDA Development.
- Syntax Highlighting: CUDA syntax highlighting is fully supported by gedit. All you have to do is open gedit and chose , syntax highlighting -> cuda and then strat writing you code =)
- Running you code: All you have to do is to cd to the directory where your source file is. (It has to be saved as .cu for it to run correctly) and then invoke the nvcc run command on it:
- Running you code: All you have to do is to cd to the directory where your source file is. (It has to be saved as .cu for it to run correctly) and then invoke the nvcc run command on it:
cd /my_directory nvcc -run my_source_code.cu
Where "my_directory" is your workspace place or the folder which contains your my_source_code.cu file and "my_source_code.cu" is the name of your source file.
Here you can give it a try on this file (Taken from here):
Here you can give it a try on this file (Taken from here):

simple.cu |
It should show an output similar to this:
Please note that if you need to install the NVIDIA SDK examples , u will need the following libraries in order that the "make" command successfully executes and generates binary files for them. Install these missing libraries via the following command:
sudo apt-get install xli libxmu-dev
For further reading and more details, please click
Related Posts you might have missed:
Getting Started with nvidia CUDA
Related Posts you might have missed:
Getting Started with nvidia CUDA