UbuntuUbuntu Based

How To Install TensorFlow on Ubuntu 24.04 LTS

In this tutorial, we will show you how to install TensorFlow on Ubuntu 24.04 LTS. TensorFlow, an open-source machine learning framework developed by Google, has revolutionized the field of artificial intelligence. Its versatility and robustness have made it a go-to choice for researchers, developers, and data scientists alike.

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 TensorFlow open-source machine learning on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • 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.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install TensorFlow on Ubuntu 24.04 LTS Noble Numbat

Step 1. Preparing Your System.

To begin, open a terminal window and update your system to ensure that you have the latest packages and security patches installed. Run the following command:

sudo apt update
sudo apt upgrade

Next, install the necessary dependencies for building TensorFlow from the source. Execute the following commands:

sudo apt install build-essential
sudo apt install python3-dev python3-venv

These commands will install the essential build tools and Python development libraries required for a smooth installation process.

Step 2. Setting Up Python Environment.

With the system prepared, it’s time to set up a Python virtual environment. Virtual environments allow you to create isolated Python instances, preventing conflicts between different projects and their dependencies. To install Python and PIP, run:

sudo apt install python3 python3-pip

Now, create a new virtual environment for TensorFlow using the following command:

python3 -m venv tensorflow_env

This will create a new directory called tensorflow_env in your current location. To activate the virtual environment, use:

source tensorflow_env/bin/activate

Your terminal prompt should now display (tensorflow_env), indicating that you’re working within the virtual environment.

Step 3. Installing TensorFlow on Ubuntu 24.04.

With the virtual environment activated, you can now proceed to install TensorFlow. If you’re using a CPU-only system, run:

pip install tensorflow

For systems with GPU support, you’ll need to verify that CUDA and cuDNN are properly installed. To check the CUDA version, use:

nvcc --version

To verify that your GPU is recognized by the system, run:

nvidia-smi

If everything is set up correctly, you can install TensorFlow with GPU support using:

pip install tensorflow[and-cuda]

This command will automatically download and install the appropriate CUDA and cuDNN versions compatible with your TensorFlow installation.

To ensure that TensorFlow is installed correctly, run a simple test script. For CPU-only systems, execute:

python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

If you have a GPU-enabled system, run:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If the installation was successful, you should see the result of the computation or a list of available GPUs, respectively.

Congratulations! You have successfully installed TensorFlow. Thanks for using this tutorial for installing TensorFlow open source machine learning platform on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the 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 an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button