Before writing any TensorFlow or Keras code, the first practical step is getting a working installation set up correctly — including choosing between CPU-only and GPU-accelerated versions, managing Python environments, and verifying that everything is functioning as expected. While the process is generally straightforward, a few common pitfalls (mismatched CUDA versions, conflicting environments, incorrect package names) trip up many newcomers, making a clear installation walkthrough a worthwhile first step.
Since TensorFlow 2.x, Keras ships bundled directly inside TensorFlow as tf.keras, meaning a single installation typically gives access to both — though standalone Keras 3 (covered later in this section) can also be installed separately for its multi-backend capabilities.
Why Does Proper Installation Matter?
Getting installation right helps to:
Avoid frustrating environment conflicts and version mismatch errors down the line
Ensure GPU acceleration is actually being used when available, for much faster training
Keep project dependencies isolated and reproducible using virtual environments
Confirm the installation works correctly before writing any real model code
Set a clean foundation for everything covered later in this section (Tensors, Keras APIs, etc.)
Avoid wasted debugging time caused by installation issues rather than actual code problems
The Installation Workflow
Whiteboard
Loading diagram...
Step 1: Check Python Compatibility
TensorFlow requires a specific range of supported Python versions, which changes with each TensorFlow release. Always check the current TensorFlow documentation for the exact supported version range before installing, since using an unsupported Python version is one of the most common installation failures.
Step 2: Create a Virtual Environment
Using a virtual environment keeps TensorFlow and its dependencies isolated from other projects, preventing version conflicts.
This single command installs TensorFlow along with tf.keras bundled inside it — no separate Keras installation is needed for standard TensorFlow 2.x usage.
GPU Support
Modern TensorFlow versions automatically include GPU support within the standard tensorflow package (rather than requiring a separate tensorflow-gpu package, as older versions once did), provided the correct NVIDIA drivers, CUDA, and cuDNN versions are installed on the system separately. Always check TensorFlow's current documentation for the exact required CUDA/cuDNN version pairing, since compatibility requirements change between releases.
Step 4: Verify the Installation
python
import tensorflow as tf
print("TensorFlow version:", tf.__version__)print("GPU available:", tf.config.list_physical_devices('GPU'))
If a GPU is properly detected and configured, tf.config.list_physical_devices('GPU') will return a non-empty list showing the available GPU device(s); an empty list means TensorFlow will fall back to CPU-only execution.
Installing Standalone Keras 3 (Multi-Backend)
As covered in the earlier Keras topic, Keras 3 can run on TensorFlow, PyTorch, or JAX as its backend. To use this multi-backend version explicitly:
pip install keras
python
import os
os.environ["KERAS_BACKEND"] = "tensorflow"# or "torch", "jax"import keras
Common Installation Methods Compared
Method
Description
Best For
pip install tensorflow
Standard installation via Python's package manager
Most users, straightforward setup
conda install tensorflow
Installation via Anaconda/Miniconda environments
Users already working within the conda ecosystem
Docker Images
Pre-built TensorFlow containers with dependencies included
Consistent, reproducible environments across machines
Google Colab
No local installation needed — runs in the browser with free GPU access
Quick experimentation without any local setup
CPU-Only vs GPU-Enabled Setup
Aspect
CPU-Only
GPU-Enabled
Installation Complexity
Simple — works out of the box after pip install
Requires matching NVIDIA drivers, CUDA, and cuDNN versions
Training Speed
Slower, especially for larger models
Significantly faster for most deep learning workloads
Deploying to a reproducible production environment
Docker image with a pinned TensorFlow version
Team project with multiple contributors
Virtual environment with a requirements.txt pinning exact versions
Experimenting with Keras 3's multi-backend feature
pip install keras + setting the KERAS_BACKEND environment variable
Best Practices
Always use a virtual environment (or conda environment) rather than installing TensorFlow globally.
Check TensorFlow's official documentation for the current supported Python and CUDA/cuDNN version matrix before installing.
Verify the installation immediately with a version check and GPU availability check.
Use Google Colab for quick experimentation if local GPU setup isn't readily available.
Pin exact package versions in a requirements file for reproducible team or production environments.
Interview Tip
A common interview question is:
"What's included when you run pip install tensorflow, and do you need to install Keras separately?"
A strong answer is:
Running pip install tensorflow installs TensorFlow along with tf.keras bundled directly inside it, so no separate Keras installation is needed for standard usage — this has been the case since TensorFlow 2.x, when Keras became TensorFlow's official high-level API. GPU support is also included in the standard package rather than requiring a separate tensorflow-gpu install like in older versions, though it still depends on the correct NVIDIA drivers, CUDA, and cuDNN being installed separately at the system level. Standalone Keras 3, with its multi-backend support for TensorFlow, PyTorch, and JAX, can also be installed separately via pip install keras if that flexibility is specifically needed.
Mentioning the historical shift away from separate tensorflow-gpu packages shows current, accurate knowledge.
Conclusion
A correct, verified installation is the essential first step before diving into TensorFlow and Keras, and modern tooling has made this process considerably simpler than in earlier years — a single pip install tensorflow now covers both TensorFlow and tf.keras, with GPU support included by default given the right system setup. With installation covered, the next topic explores Tensors, the fundamental data structure that everything in TensorFlow is built around.
Author & Technical Reviewer
Written by:Vinay Adari
Technically reviewed by:ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 22, 2026
Last updated
Aug 22, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.