Step 1: Set Up Your TensorFlow Environment
Follow official pip installation for your OS (Linux/macOS/Windows/WSL2).
Prerequisites
- Python 3.9-3.12
- pip >=19.0 (Linux), >=20.3 (macOS)
Quick Install (CPU)
python3 -m venv tf_env
source tf_env/bin/activate # Linux/macOS
# or tf_env\Scripts\activate # Windows
pip install --upgrade pip
tensorflow
GPU (Linux/WSL2)
pip install 'tensorflow[and-cuda]'
Verify
import tensorflow as tf
print(tf.reduce_sum(tf.random.normal([1000, 1000])))
print(tf.config.list_physical_devices('GPU')) # If GPU
Use Google Colab for no-install option.
See full guide: https://www.tensorflow.org/install/pip