How to Install TensorFlow on Windows

This tutorial will show you how to install TensorFlow on Windows. You do need need any special hardware. Although, you should be running Windows 10 on a 64-bit processor.

TensorFlow maintains a number of Docker images that are worth trying if you do not want to fight with version numbers. Read about how to use the TensorFlow Docker images here.

Prerequisites

We need to pay attention to version numbers, as TensorFlow works with only certain versions of Python. Head to this page to look at the available versions of TensorFlow.

At the time of writing, the most recent version of TensorFlow available is 2.2.0. By looking at the table, we can see that it requires Python version 3.5-3.8.

Version Python version Compiler Build tools
tensorflow-2.2.0 3.5-3.8 MSVC 2019 Bazel 2.0.0

Install Anaconda

While you could install TensorFlow directly on your system next to whatever Python version you wish, I recommend doing everything through Anaconda.

Anaconda provides a terminal prompt and can easily help you switch between Python environments. This proves to be extremely helpful when you want to run multiple versions of Python and TensorFlow side by side.

Head to anaconda.com and download the Individual Edition for your operating system (Windows x64). Run the Anaconda installer and accept all the default settings.

When that is complete, run the Anaconda Prompt (anaconda3).

The Anaconda Prompt

Install TensorFlow

In the terminal, we want to create a new Python environment. This helps us keep various versions of Python and TensorFlow separate from each other (such as separate CPU and GPU versions). Enter the following commands:

conda create --name tensorflow-cpu
conda activate tensorflow-cpu

Check the version of Python that came with Anaconda using the following command:

python --version

If you want to use different version of Python, you can enter the following command (x.x is the version of Python). For example, I will install 3.7, as that falls in the acceptable version range for TensorFlow 2.2.0, which requires Python 3.5-3.8:

conda install python=x.x

If you wish to also install Jupyter Notebook, you can do so with the following:

conda install jupyter

Note that if you switch environments in Anaconda (e.g. to tensorflow-gpu), you will need to reinstall packages, as the each environment keeps everything separate.

If we run pip on its own to install TensorFlow, it will likely try to pull an outdated version. Since we want the newest release, we’ll have to tell pip where to download a specific wheel file (.whl). 

Navigate to the TensorFlow Pip Install page and look at the Package Location list.

Go to the Windows section and find the CPU-only version that supports your version of Python. For me, this will be the .whl file listed with Python 3.7 CPU-only. Note that the required versions are listed in the filename: CPU-only (_cpu), TensorFlow version (-2.2.0), and supported Python version (-cp37). Highlight and copy the .whl file URL.

Python pip .whl file location to install TensorFlow on Windows

In Anaconda, enter the following command and replace <wheel_url> with the URL that you just copied:

python -m pip install <wheel_url>

Press ‘enter’ and wait a few minutes while TensorFlow installs.

Install TensorFlow with Anaconda

When it’s done, go into the Python command line interface:

python

Check if TensorFlow is installed by entering the following commands:

import tensorflow as tf
print(tf.__version__)

You should see the version of TensorFlow printed out (e.g. “2.2.0”).

How to check TensorFlow version in Python

Close the Anaconda prompt.

Running TensorFlow

When you’re ready to work with TensorFlow, open the Anaconda Prompt and enter the following:

conda activate tensorflow-cpu

Now, you can use TensorFlow from within the Anaconda Prompt or start a Jupyter Notebook session. 

jupyter notebook

This article gives a good introduction to using Jupyter Notebook.

If you want to install a Python package, you can do so inside of the Anaconda Prompt. Make sure that you are in the desired environment (e.g. tensorflow-cpu) first and that Jupyter Notebook is not running (quit Jupyter Notebook by pressing ctrl+c inside the Anaconda Prompt). From there, install a package with:

python -m pip install <name_of_package>

You can also install a package from inside Jupyter Notebook by running the following command in a cell:

!python -m pip install <name_of_package>

For example, I installed matplotlib here:

Install Python package from within Jupyter Notebook

Going Further

If you have an NVIDIA graphics card capable of running CUDA, you might be able to speed up some of your TensorFlow applications by enabling GPU support. You will need to install several drivers, and I recommend installing tensorflow-gpu in a separate Anaconda environment. See this guide on installing TensorFlow with GPU support on Windows.

See the following videos if you are looking for an introduction on TensorFlow and TensorFlow Lite:

Writing Your Own UPM Module: Getting Started

Intel-IoT_LogoImage courtesy of Intel iot-devkit GitHub account

UPM (Useful Packages and Modules) is a high-level library that relies on MRAA to talk to hardware peripherals over GPIO, SPI, UART, etc. Both libraries were created by Intel and come packaged with the Galileo and Edison boards. MRAA has support for other single board computers, like the Raspberry Pi and Beaglebone Black, according to the MRAA documentation.

MRAA is the low-level driver that controls the individual bits for the GPIO. UPM is a collection of libraries (modules) that provides the necessary software for various sensors, motor drivers, etc.

Continue Reading
Edison and RFduino

Using Python and BLE to Receive Data from the RFduino

Edison and RFduino

It’s should be no surprise that I enjoy working with the Edison. It may not be as easy to work with as the Raspberry Pi, but I still like it.

My current project includes getting the Edison to talk Bluetooth Low Energy (BLE) to another device. The RFduino is the device in question, as I should be able to receive data as well as control peripherals attached to the RFduino. The final project will be an addition to the IoT YouTube series that I am working on (at SparkFun). I’m not spoiling anything!

Continue Reading