DebianDebian Based

How To Install TensorFlow on Debian 12

Install TensorFlow on Debian 12

In this tutorial, we will show you how to install TensorFlow on Debian 12. TensorFlow is an end-to-end open-source platform for machine learning. The flexible architecture allows you to deploy computation across a variety of platforms, from desktops to clusters of servers to mobile and edge devices.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the TensorFlow machine learning platform on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for TensorFlow.
  • A user account with sudo privileges to execute administrative commands.

Install TensorFlow on Debian 12 Bookworm

Step 1. We’ll first refresh our package repositories so we download the latest versions of any required software during this installation guide:

sudo apt update
sudo apt upgrade

Step 2. Installing Python and Pip.

TensorFlow supports Python 3.8 and higher. We need Python and pip (the Python package manager) on our system to install TensorFlow itself later on.

Run this command to install both Python 3 and pip:

sudo apt install python3-pip

Once done, you can check the installed versions:

python3 --version
pip --version

Step 3. Set Up a Virtual Environment.

It’s best practice to create a virtual environment for TensorFlow. A virtual env keeps dependencies isolated from other Python projects on your system.

First, install the virtual environment package:

sudo apt install python3-venv

Then create and activate a virtual environment for TensorFlow with these commands:

mkdir tensorflow
cd tensorflow
python3 -m venv tensorflow
source tensorflow/bin/activate

This makes a directory called tensorflow, changes into it, and creates a Python virtual environment named tensorflow inside it, and activates the virtual environment.

Even though we installed pip earlier, virtual environments create isolated package installations. So we should upgrade pip inside our virtual env to the latest:

pip install --upgrade pip

Step 4. Installing TensorFlow on Debian 12.

Now we’re ready to use pip for installing TensorFlow inside our active virtual environment:

pip install --upgrade tensorflow

This downloads and installs the latest TensorFlow version from the Python Package Index repository.

Let’s check that TensorFlow is properly installed by querying the version:

python -c "import tensorflow as tf; print(tf.__version__)"

This should print out the installed TensorFlow version, such as 2.11.0.

We can also test a short TensorFlow program:

python -c "import tensorflow as tf; print(tf.add(1, 2).numpy())"

Congratulations! You have successfully installed TensorFlow. Thanks for using this tutorial to install the latest version of the TensorFlow machine learning platform on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official TensorFlow website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button