How To Install TensorFlow on Debian 11

In this guide, we want to teach you How To Install TensorFlow on Debian 11.

TensorFlow is an open-source end-to-end platform for creating Machine Learning applications. It is a symbolic math library that uses dataflow and differentiable programming to perform various tasks focused on the training and inference of deep neural networks. It allows developers to create machine-learning applications using various tools, libraries, and community resources.

Currently, the world’s most famous deep learning library is Google’s TensorFlow. Google product uses machine learning in all of its products to improve the search engine, translation, image captioning, or recommendations.

This tutorial will explain how to install TensorFlow in a Python virtual environment on Debian 11.

Install TensorFlow on Debian 11

To set up TensorFlow, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Now follow the steps below to complete this guide.

Install Python 3 and Pip on Debian 11

Because we want to install TensorFlow in a Python virtual environment, we need to have Python installed on our server.

By default, Debian 11 ships with Python 3. To verify it, check your Python version:

python3 --version
Output
Python 3.9.2

If you don’t have Python 3 installed on your server, you can install it by running the command below:

sudo apt install python3

Then, install pip on Debian 11 by running the command below:

sudo apt install python3-pip

Verify your installation by checking its version:

pip --version
Output
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

Install Python virtual environment on Debian 11

The recommended way to create a virtual environment is by using the venv module, which is provided by the python3-venv package.

First, update your local package index with the command below:

sudo apt update

Then, use the command below to install Python virtual environment:

sudo apt install python3-venv

Create a virtual environment on Debian 11

At this point, you need to create and activate a Python-based virtual environment.

First, create a new directory for your TensorFlow project and switch to it, here we named it tf_project.

# mkdir tf_project
# cd tf_project

Then, from your TensorFlow project directory, run the command below to create the virtual environment:

python3 -m venv venv

This command creates a directory named venv, which contains a copy of the Python binary, the Pip package manager, the standard Python library, and other supporting files.

At this point, you need to activate your virtual environment with the following command:

source venv/bin/activate

Once activated, the virtual environment’s bin directory will be added at the beginning of the system $PATH variable. Also, the shell’s prompt will change, and it will show the name of the virtual environment you’re currently in. In this example, that is (venv).

TensorFlow installation requires pip version 19 or higher. Run the following command to upgrade pip to the latest version:

(venv) $ sudo pip install --upgrade pip

Installing TensorFlow on Debian 11

At this point, you can start your TensorFlow installation on your server. To do this, run the command below:

(venv) $ sudo pip install --upgrade tensorflow

This command will install all the necessary packages along with TensorFlow.

Note: Within the virtual environment, you can use pip instead of pip3 and python instead of python3.

When your installation is completed, verify it by checking its version:

(venv) $ python -c 'import tensorflow as tf; print(tf.__version__)'

For more information, you can visit the TensorFlow Learning Page.

Conclusion

At this point, you learn to Install TensorFlow in a Python virtual environment on Debian 11.

Hope you enjoy it.

You may be interested in these articles:

How To Install and Use Docker on Debian 11

Install and Configure Umami Software on Debian 11

How To Install Anaconda on Debian 11

How To Install Node.js on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!