How to install CUDA in Ubuntu.

TensorFlow is an open-source software library for dataflow programming across a range of tasks. It is a symbolic math library, and also used for machine learning applications such as neural networks.
Now we see a general way to install CUDA drivers from Nvidia on Ubuntu. Kindly note that the tutorial somehow remains the same for other Linux based Distro’s as well.

To install the Nvidia driver you can do the following:

In Ubuntu somehow hunt for “Additional Drivers” (You might also do System Settings->Software and Updates->Additional Drivers)

In the menu that appears select one of the Nvidia Drivers and click “Apply Changes”.(This step uses the internet)

Reboot your system.

Open a terminal window and type nvidia-smi. If your driver has been installed correctly you should see something like :

You can easily install CUDA according to the previous link. Now run all the commands one by one as root user.

apt-get install linux-headers-$(uname -r)

Download a deb file from here and then install the .deb file (replace name accordingly)

dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb

then run:

apt-get update
apt-get install cuda

Voila, You’re done !