How to Install Tensorflow on Ubuntu 18.04 in Google Cloud. TensorFlow is open-source machine learning software developed by Google which is used to train neural networks.
In this tutorial, we’ll install TensorFlow’s “CPU support only” version. This installation is ideal for people looking to install TensorFlow, but who don’t have Nvidia graphics card.
- A Compute Engine Instance running with atleast 1 GB RAM, see the Setting up Compute Engine Instance.
Setting Up Python 3
Ubuntu 18.04 ships with both Python 3 and Python 2 pre-installed. To make sure all packages are up-to-date, start by updating the system.
SSH to your Compute Engine instance and begin to execute the following commands.
sudo apt update
sudo apt -y upgrade
Once the update and upgrade is complete verify the Python installation using the following command.
Install the Required Packages
sudo apt install python3-pip python3-dev
Once Python is set up, and pip and other tools are installed, we can set up a virtual environment to install Tensorflow.
Setting Up a Virtual Environment
We will be using the virtualenv module here, which is part of the standard Python 3 library.
sudo -H pip3 install virtualenv
Activate the virtual environment by typing.
Your prompt should change to indicate that you are now operating within a Python virtual environment. It will look something like this:
With your virtual environment activated you can install Tensorflow.
pip install --upgrade tensorflow
Once the installation is completed you can verify the installation using the following command.
python -c 'import tensorflow as tf; print(tf.version)'
Now you have learned how to install Tensorflow on Ubuntu 18.04 on Google Cloud Platform.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.