Install Tensorflow (CPU Only) on Ubuntu 20.04|18.04 / Debian 10|9

In this blog post, we will install TensorFlow Machine Learning Library on Ubuntu 20.04|18.04 / Debian 10|9. If you need Tensorflow GPU, you should have a dedicated Graphics card on your Ubuntu/Debian system — NVIDIA, AMD e.t.c. The software installed for Tensorflow GPU is CUDA Toolkit.

To Install Tensorflow (CPU Only) on Ubuntu 20.04|18.04, you’ll go with Tensorflow no GPU supported version which requires Python 2.7 or Python 3.3+. Install Python and required modules by running the following commands:

# Python2

sudo apt update

sudo apt -y install python python-pip python-setuptools python-dev



# Python 3

sudo apt update

sudo apt -y install python3 python3-pip python3-setuptools python3-dev

Then install Tensorflow using pip Python package manager.

#pip2

sudo pip install --upgrade tensorflow requests



#pip3

sudo pip3 install --upgrade tensorflow requests

If you have CUDA-enabled GPU cards, then you can install the GPU package.

#Python2

sudo pip install tensorflow-gpu



#Python3

sudo pip3 install tensorflow-gpu

But don’t forget that GPU packages require a CUDA®-enabled GPU card.

Verify that your Tensorflow is working fine.

#python2

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"



#python3

python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Output:

2018-12-19 00:53:36.272184: I tensorflow/core/platform/cpu_feature_guard.cc:141] 

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

tf.Tensor(820.4219, shape=(), dtype=float32)

Running a test Model:

mkdir ~/tensorflow_projects

cd ~/tensorflow_projects

git clone https://github.com/tensorflow/models.git

export PYTHONPATH="$PYTHONPATH:$(pwd)/models"

cd models/official/mnist

python mnist.py

TensorBoard is a group of visualization tools that make it easier to understand, debug, and optimize TensorFlow programs. Use TensorBoard to visualize your TensorFlow graph, plot quantitative metrics about the execution of your graph, and show additional data like images that pass through it.

Start TensorBoard by running:

mkdir ~/tensor_logs

tensorboard --logdir=~/tensor_logs

On running the tensorboardcommand, the output like below will be printed in your screen.

TensorBoard 1.12.1 at http://ubuntu-01:6006 (Press CTRL+C to quit)

You can kill TensorBoard process by Pressing CTRL+C

Not that by default Tensorflow outputs are stored under the /tmp directory. When TensorBoard is fully configured, access the URL on http://[ServerHostname|IPAddress]:6006. The Dashboard looks like this:

install-tensorflow-ubuntu-18.04

You can also run TensorFlow in a docker container. If you don’t have a Docker Engine installed on Ubuntu/Debian Linux, our guide should come in handy.

How to install Docker CE on Ubuntu / Debian / Fedora / Arch / CentOS

The TensorFlow Docker images are already configured to run TensorFlow. A Docker container runs in a virtual environment and is the easiest way to set up GPU support.

Download TensorFlow Docker image:

docker pull tensorflow/tensorflow

Once Downloaded, start Jupyter notebook server by running:

docker run -it -p 8888:8888 tensorflow/tensorflow

If you just want to run a TensorFlow test, use:

docker run -it --rm tensorflow/tensorflow \

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Read more about Running TensorFlow in Docker from the official website.

https://www.computingpost.com/install-tensorflow-cpu-only-on-ubuntu-20-0418-04-debian-109/?feed_id=20345&_unique_id=637b0df1e748e

--

--

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.

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
ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.