What is Tensorflow?

So, lets start with what is tensorflow?

  • Tensorflow is an open-source library with is capable of running machine learning algorithms.
  • It was developed by google brain’s team(Second-gen, DistBelief was the 1st).
  • Now-a-days it is widely used by many companies, Machine Learning algorithmist, Students, teachers, etc.
  • This library can be used in python mainly. Some interfaces are available to execute and construct graph in C++, Java and Go. Tensorflow also has a JavaScript library(TensorFlow.js)
  • TensorFlow supports CUDA(CUDA is a parallel computing platform and API model created by Nvidia.). It helps to raise the performance of our program.

Installation of TensorFlow GPU in Fedora

  • In the first step we need to check that we have a NVIDIA GPU:
sudo lspci | grep -i NVIDIA    #information about all PCI buses and devices in the computer. 

(In a line it mentions about your VGA adapter)

dnf config-manager --add-repo=http://negativo17.org/repos/fedora-nvidia.repo

Then we need to install the NVIDIA driver, and the necessary libraries for cuda operations.

  • Now we need to complete the process to install CUDA and NVIDIA drivers we need to type:
    • dnf install kernel-devel dkms-nvidia  nvidia-driver-cuda
      dnf install cuda-devel cuda-cudnn-devel
  • After the process completes reboot your computer.
  • After rebooting type this
    • sudo lsmod  | grep nv
    • This will show somting like this:
      • nvidia_drm             45056  0
        nvidia_modeset        901120  1 nvidia_drm
        nvidia_uvm            684032  0
        nvidia              13914112  2 nvidia_modeset,nvidia_uvm
        drm_kms_helper        159744  2 i915,nvidia_drm
        drm                   352256  5 i915,nvidia_drm,drm_kms_helper
  • Now we move on to the main step, Installation of TensorFlow for the GPU:
    • Install the TensorFlow build, which is built to be ready for the latest versions(python 3.x)
      • virtualenv --system-site-packages -p python3 ~/env3
        . ~/env3/bin/activate
        
        
        pip install tf-nightly-gpu
  • Now we will test that our installation works or not:
    • import tensorflow as tf
      
      a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
      b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
      c = tf.matmul(a, b)
      
      MySession = tf.Session(config=tf.ConfigProto(log_device_placement=True))
      print(MySession.run(c))

 

NOTE

If it shows  /dev/nvidia0 does not exist then you’re not running on the Nvidia card as a display adapter, or you have not installed the nvidia-modprobe.