Installing TensorFlow

After preparing the GPU environment for TensorFlow, we are now ready to install TensorFlow in GPU mode. But for going through the TensorFlow installation process, you can first install a few helpful Python packages that will help you in the next chapters and make your development environment easier.

We can start by installing some data manipulation, analysis, and visualization libraries by issuing the following commands:

sudo apt-get update && apt-get install -y python-numpy python-scipy python-nose python-h5py python-skimage python-matplotlib python-pandas python-sklearn python-sympy
sudo apt-get clean && sudo apt-get autoremove
sudo rm -rf /var/lib/apt/lists/*

Next, you can install more useful libraries, such as the virtual environment, Jupyter Notebook, and so on:

sudo apt-get update
sudo apt-get install git python-dev python3-dev python-numpy python3-numpy build-essential  python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev
sudo apt-get install -y libfreetype6-dev libpng12-dev
pip3 install -U matplotlib ipython[all] jupyter pandas scikit-image

Finally, we can start to install TensorFlow in GPU mode by issuing the following command:

pip3 install --upgrade tensorflow-gpu

You can verify the successful installation of TensorFlow using Python:

python3
>>> import tensorflow as tf
>>> a = tf.constant(5)
>>> b = tf.constant(6)
>>> sess = tf.Session()
>>> sess.run(a+b)
// this should print bunch of messages showing device status etc. // If everything goes well, you should see gpu listed in device
>>> sess.close()

You should get the following output in the terminal:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset