How to install Tensorflow 1.7.0 using official pip package

Easiest method to install official pre-built tensorflow pip packages for both CPU and GPU versions on Ubuntu and Windows.

Hello everyone. This is going to be a tutorial on how to install tensorflow using official pre-built pip packages. To install tensorflow with pip packages is easier as compared to building using CMake or Bazel. Pre-built pip package are fully tested officially. However, since they are configured in such a way that they can support legacy hardware too, using pip package may not use full capability on your new and powerful hardware. Building pip package the solution to fully optimize tensorflow to use full capability of your hardware. However, building is a time-consuming process and generally recommended for advanced users only. If you are looking to build tensorflow (with CUDA 10.0) instead, you can check out our other blog posts:

  1. For Ubuntu
  2. For Windows 10

In this tutorial, we will look at how to install tensorflow CPU and GPU both for Ubuntu as well as Windows OS. For our purpose, we will look at installing the latest version tensorflow, tensorflow 1.7.0, at the time this blog is published. To install tensorflow in any OS, I highly recommended using virtual environment setup (conda, virtualenv etc.). Currently only 64-bit python is supported by Tensorflow.

We have also performed speed comparison on the tensorflow 1.5.0 with CUDA 9 and cuDNN 7.5 support with tensorflow 1.4.1 with CUDA 8 and cuDNN 6 to calculate just how faster the new version of tensorflow is in comparison. You can click on the link here to check that out.

There must be 64-bit python installed tensorflow does not work on 32-bit python installation.

For Ubuntu 16.04 64bit OS:

Install CPU Version of Tensorflow:

CPU version of tensorflow is recommended for new users of tensorflow. Unless you are handling large datasets, CPU version of tensorflow works just fine. Also, this is the simplest method to install tensorflow.

Step1: Download whl file

Goto and download whl pacakage related to your python version and os.

For eg. If your tensorflow version is 1.7.0, your python version is 3.5, and OS is linux then select tensorflow-1.7.0-cp35-cp35m-manylinux1_x86_64.whl

Step 2: Install whl file

Create a new virtual environment and activate it then install the whl file using the command. If you are having trouble setting up a virtual environment, you can refer to our other article here.

for python 2:

pip2 install [whl file path]

for python 3:

pip3 install [whl file path]

Step 3: Verify tensorflow installation

Verify tensorflow using following commands:

$ python3

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
'Hello, TensorFlow!'
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> + b)
>>> sess.close()

This is all you need to do to install tensorflow CPU version on Ubuntu 16.04.

Install GPU Version of Tensorflow:

Using GPU version of tensorflow will greatly speed up training dataset time. Once you are working with large datasets, it is impractical to rely only on CPU for deep learning. Tensorflow GPU is recommended for intermediate to advanced users and anyone who works with handling large dataset. Advanced users who want to build pip package to get optimum performance can follow the link at the top of the article to build tensorflow gpu for ubuntu.

Step 1: Update and Upgrade your system:

sudo apt-get update 
sudo apt-get upgrade

Step 2: Verify You Have a CUDA-Capable GPU:

lspci | grep -i nvidia

Note GPU model. eg. GeForce 840M

If you do not see any settings, update the PCI hardware database that Linux maintains by entering update-pciids (generally found in /sbin) at the command line and rerun the previous lspci command.

If your graphics card is from NVIDIA then go to and verify if listed in CUDA enabled GPU list.

Step 3: Verify You Have a Supported Version of Linux:

To determine which distribution and release number you’re running, type the following at the command line:

uname -m && cat /etc/*release

The x86_64 line indicates you are running on a 64-bit system which is supported by Cuda 9.0

Step 4: Install Dependencies:

sudo apt-get install build-essential

sudo apt-get install cmake git unzip zip

sudo apt-get install python2.7-dev python3.5-dev python3.6-dev pylint

Step 5: Install linux kernel header:

Goto terminal and type:

uname -r

You can get like “4.10.0-42-generic”. Note down linux kernel version.

To install linux header supported by your linux kernel type the following command:

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

Step 6: Download the NVIDIA CUDA Toolkit:

Go to this link and download Installer for Linux > x86_64 > Ubuntu > 16.04 > deb[network]

I highly recommend network installer to get updated gpu driver supported by your linux kernel.

For, direct download


If you have Cuda 9.1 or other version installed then this tensorflow prebuilt package will not work. Remove nvidia cuda related files (drivers, Cuda Toolkit, etc)

sudo apt-get purge nvidia*
sudo apt-get auto-remove

Installation Instructions:

sudo apt-key adv --fetch-keys
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-9.0

Step 7: Reboot the system to load the NVIDIA drivers.

14 Comments on How to install Tensorflow 1.7.0 using official pip package

  1. Great. This was really helpful. Not really used to windows but these steps saw me through. Of course I have to do back and forth with versions but still, this made life pretty easy. thanks a ton.

  2. I am simply trying to install the CPU version on Windows 7. The installation has gone fine but on trying import tensorflow I get:

    File “C:\Program Files\Python36\lib\importlib\”, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: DLL load failed: The specified procedure could not be found.

    From what I read I think this is something to do with the PATH but have reached an impass

  3. I had a successful tensorflow with GPU installation from tensorflow_gpu-1.7.0rc1-cp36-cp36m-win_amd64.whl untill tried to update by running tensorflow_gpu-1.7.0-cp36-cp36m-win_amd64.whl

    Everything looked fine untill
    Found existing installation: tensorboard 1.6.0
    Uninstalling tensorboard-1.6.0:
    Successfully uninstalled tensorboard-1.6.0
    Found existing installation: tensorflow-gpu 1.7.0rc1
    Uninstalling tensorflow-gpu-1.7.0rc1:
    Traceback (most recent call last):
    File “c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\”, line 544, in move
    os.rename(src, real_dst)
    FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘c:\\program files (x86)\\microsoft visual studio\\shared\\python36_64\\lib\\site-packages\\tensorflow\\contrib\\tensor_forest\\hybrid\\python\\models\\__pycache__\\stochastic_hard_decisions_to_data_then_nn.cpython-36.pyc’ ->

    After this tensorflow fails. Please help the cleanup… I don’t have the relevant restore point.

    • Rename python36_64 with other name and download 64 bit python zip and extract it to same name then install tensorflow in fresh python package.

  4. I am trying to install sonnet to try the Differentiable neural computer example so far no luck.
    I tried installing it from source because I could not get the packages to work.
    File “/home/joshua/sonnet/sonnet/python/modules/”, line 24, in
    from sonnet.protos import module_pb2
    ImportError: cannot import name ‘module_pb2’

  5. I am running ubuntu linux 17.10 and gcc 7 seems to be a issue but maby something else is wrong it is not responding.
    Python 3.6.3 (default, Oct 3 2017, 21:45:48)
    [GCC 7.2.0] on linux
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import tensorflow as tf
    >>> hello = tf.constant(‘Hello, TensorFlow!’)
    >>> sess = tf.Session()
    2018-03-08 13:00:07.668057: I tensorflow/core/platform/] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
    2018-03-08 13:00:07.817236: I tensorflow/stream_executor/cuda/] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
    2018-03-08 13:00:07.817807: I tensorflow/core/common_runtime/gpu/] Found device 0 with properties:
    name: GeForce 940M major: 5 minor: 0 memoryClockRate(GHz): 1.176
    pciBusID: 0000:04:00.0
    totalMemory: 1.96GiB freeMemory: 1.61GiB
    2018-03-08 13:00:07.817849: I tensorflow/core/common_runtime/gpu/] Adding visible gpu devices: 0

  6. Greatly detailed tutorial running windows 10 and linux ubuntu 17.10 under cpu.
    Ran a LTSM ANN Tutorial from tensorflows website took hours trying gpu under linux python 3.6 so had to change version number
    sudo apt-get install python2.7-dev python3.5-dev pylint
    sudo apt-get install python2.7-dev python3.6-dev pylint

1 Trackbacks & Pingbacks

  1. Important Links | Tejalal Choudhary

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.