If you’re using Ubuntu 24.04 and want to get started with machine learning, TensorFlow is one of the best frameworks to begin with. Whether you’re building neural networks or running pre-trained models, this guide will walk you through installing TensorFlow on your system—no unnecessary steps, just what you need.
Step 1: Update Your System
Open your terminal and make sure your system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Python and pip
Ubuntu 24.04 should come with Python 3.10 or later. Check your version:
python3 --version
If Python is missing or outdated, install it:
sudo apt install python3 python3-pip -y
Optional: Install venv
to keep your TensorFlow environment isolated:
sudo apt install python3-venv -y
Step 3: Create a Virtual Environment (Recommended)
Create and activate a virtual environment in your project folder:
python3 -m venv tf-env
source tf-env/bin/activate
You’ll know it’s activated when you see (tf-env)
in your terminal prompt.
Step 4: Upgrade pip
TensorFlow requires the latest version of pip. Upgrade it with:
pip install --upgrade pip
Step 5: Install TensorFlow
Now install TensorFlow. For most users, the CPU version is fine:
pip install tensorflow
If you have an NVIDIA GPU and want to take advantage of it, make sure you’ve installed the correct CUDA and cuDNN libraries, then install:
pip install tensorflow[and-cuda]
Note: As of TensorFlow 2.11+, GPU support for Linux comes through the
tensorflow[and-cuda]
extra.
Step 6: Test Your Installation
Launch Python:
python
And run the following:
import tensorflow as tf
print("TensorFlow version:", tf.__version__)
If everything is working, you should see the TensorFlow version printed without any errors.
Troubleshooting Tips
- Missing dependencies? Run
sudo apt install build-essential
to make sure required compilers and tools are installed. - Using Jupyter? Run
pip install notebook
to add notebook support to your environment. - GPU not detected? Double-check your CUDA toolkit version with
nvidia-smi
and make sure it matches TensorFlow’s compatibility list.
Conclusion
You’re all set. With TensorFlow installed on Ubuntu 24.04, you can start training models, experimenting with AI, or running ML pipelines. Keep your environment isolated, stay updated, and you’ll avoid most of the common headaches.
Want a tutorial on building your first TensorFlow model? Let me know in the comments.
Leave a Reply