# How to Install Tensorflow on Ubuntu 22.04

> URL: https://www.atlantic.net/dedicated-server-hosting/how-to-install-tensorflow-on-ubuntu-22-04/ | Published: 2024-07-04 | Updated: 2024-08-17 | Author: Hitesh Jethva

TensorFlow, developed by Google, is a powerful open-source platform for machine learning and artificial intelligence. It’s used by researchers and developers worldwide to build and deploy machine learning models. Whether you’re working on a small hobby project or a large-scale application, TensorFlow provides the tools you need.

In this article, we’ll walk you through each step of the installation process of TensorFlow on Ubuntu 22.04.

## Step 1 – Update and Upgrade Your System

Before anything else, let’s ensure your system is up to date. Open your terminal and run the following commands:

```bash
apt update -y 
apt upgrade -y
```

Updating your system is crucial as it ensures you have the latest security patches and features, setting a strong foundation for TensorFlow installation.

## Step 2 – Install Python

Next, you’ll need Python, which is essential for running TensorFlow. To install Python, enter the command:

```bash
apt install python3 -y
```

You can verify the installation by checking the version:

```bash
python3 --version
```

You should see an output like Python 3.10.12. Great, Python is installed!

```bash

Python 3.10.12
```

## Step 3 – Install Pip, Virtual Environment, and Development Tools

To manage your Python packages, you’ll need Pip. Also, creating a virtual environment is a good practice to keep your TensorFlow installation isolated. Install Pip, the virtual environment module, and development tools with:

```bash
apt install python3-pip python3-venv python3-dev -y
```

## Step 4 – Set Up Your Project Directory

Next, create a directory for your project and navigate to the directory:

```bash
mkdir project  
cd project
```

Now you’re in your project directory. Perfect!

## Step 5 – Create and Activate a Virtual Environment

Creating a virtual environment is crucial to avoid conflicts with other Python packages. Create one with the following command:

```bash
python3 -m venv venv
```

Activate the virtual environment:

```bash
source venv/bin/activate
```

You’ll notice your terminal prompt changes, indicating the virtual environment is active.

## Step 6 – Install TensorFlow

With the virtual environment activated, you can now install TensorFlow. Use Pip to install the latest version:

```bash
pip3 install --upgrade TensorFlow
```

TensorFlow will be downloaded and installed in your virtual environment. This might take a few minutes, so grab a coffee while you wait!

## Step 7 – Verify the Installation

To ensure TensorFlow is installed correctly, you can check the installation details. Run:

```bash
python3 -m pip show TensorFlow
```

You should see an output similar to this:

```bash
Name: tensorflow
Version: 2.16.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /root/project/venv/lib/python3.10/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, ml-dtypes, numpy, opt-einsum, packaging, protobuf, requests, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
Required-by:
```

This confirms that TensorFlow is installed and ready to use.

Once you’re done, you can deactivate the virtual environment by simply running:

```bash

deactivate
```

This will return your terminal to its normal state.

## Conclusion

In this article, we’ve walked through the steps to install TensorFlow on Ubuntu 22.04. We started by updating and upgrading the system, then installed Python and Pip. We set up a project directory, created a virtual environment, and installed TensorFlow. Finally, we verified the installation and deactivated the virtual environment. Try to install TensorFlow on [dedicated server hosting](https://www.atlantic.net/dedicated-server-hosting/) from Atlantic.Net!
