Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install TensorFlow on Ubuntu

Update Ubuntu, install pip and add TensorFlow in a virtual environment.

VPS and Cloud Servers2 min read5 screenshots

What you need

  • A current Ubuntu release.
  • Python 3.9 or newer, check the TensorFlow site for the supported range.
  • A recent pip.
  • CUDA and a compatible NVIDIA GPU, only if you want GPU support.

Step 1: Update Ubuntu

sudo apt update && sudo apt full-upgrade
Updating Ubuntu

Step 2: Install pip

Check if pip exists:

pip --version
Checking the pip version

If it is missing, install it with the venv module:

sudo apt install python3-pip python3-venv
Installing pip

Step 3: Install TensorFlow

Use a virtual environment so TensorFlow does not mix with system packages:

python3 -m venv ~/tf-env
source ~/tf-env/bin/activate
pip install tensorflow
Installing TensorFlow with pip
Note: Newer Ubuntu releases block pip install into the system Python. A virtual environment avoids that error.

Step 4: Check it

python3

Then in the Python shell:

import tensorflow as tf
print(tf.__version__)
The TensorFlow version

What is TensorFlow

TensorFlow is a free machine learning library from Google. It is used to build and train neural networks for images, text, speech and prediction.

Key features:

  • Keras API for quick model building.
  • CPU and GPU support.
  • TensorBoard for charts of your training.
  • Deployment options for servers, mobile and browsers.

Quick recap

  • Update Ubuntu and install python3-pip and python3-venv.
  • Create a virtual environment and run pip install tensorflow.
  • Check with tf.__version__.