Setting up Tensorflow and Keras using pip on your local machine — 2020!

What is PIP?

PIP is a recursive acronym that stands for “PIP Installs Packages” or “Preferred Installer Program.” It’s a command-line utility that allows you to install, reinstall, or uninstall PyPI packages with a simple and straightforward command: pip.

Installing Python and PIP

  1. Go to https://www.python.org/downloads/ and scroll down to the bottom of the webpage to download macOS 64-bit/32-bit installer for macOS and Windows x86–64 executable installer for Windows.

2. Once you’ve downloaded it, double click the installed file, and be sure to select the custom option for install. This takes you into a configuration dialog where you can choose pip as an option to install.

3. It is recommended to select all Optional Features and click Next.

4. Again select all in Advanced Options, and click install.

5. Once the file is installed, check if you’ve installed the correct version. (python 3.7.4).

Open terminal(macOS) or command prompt(Windows) and type: 
python --version

5) If you’ve installed the right version, then let’s test the interpreter. (An interpreter is a program that reads and executes code).

In the same terminal, type:
python (This should open the python interpreter)
Now you can exit the Python interpreter by typing:
exit()

6) Lastly, test your pip installation.

Type: pip -V (This should return a version number eg: 19.0.3)

(You’re now good to go with the Python interpreter and pip)

Installing CUDA:

  1. At the time of writing, the TensorFlow supports CUDA 9.0, so go the link and download CUDA Toolkit 9.0. Here’s the link to downloads.

2) Once downloaded, click and install. It is very straightforward so you won’t have trouble navigating.

3) Once the installation is completed, let’s start with installing Tensorflow and Keras.

Installing Tensorflow and keras:

  1. Open a terminal as an administrator and update your pip. (To do this you right-click the terminal and select ‘Run as administrator’).

2) To install Tensorflow, type

pip install --upgrade tensorflow

3) To install Keras, type

pip install --upgrade keras

4) Open Interpreter after Tensorflow and Keras are installed.

python

5) In the python interpreter type

import tensorflow
import keras

6) If the code runs without errors, then you’ve installed accurately.

7) Exit out of the interpreter.

exit()

That’s all you need to get started with Machine Learning on your local machine. :)

Hello, World in Tensorflow:

  1. Open Python Interpreter on your terminal by typing: python
  2. Copy-paste the following code line by line:
from __future__ import print_function
import tensorflow as tf
hello = tf.constant(‘Hello, World of AI’)
sess = tf.Session()
print(sess.run(hello))
Output: ‘Hello, World of AI!’

--

--

Passionate about making the world a better place by cultivating relationships and developing technologies.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stephen Joel

Stephen Joel

15 Followers

Passionate about making the world a better place by cultivating relationships and developing technologies.