0
0
TensorFlowml~5 mins

Installation and GPU setup in TensorFlow

Choose your learning style9 modes available
Introduction

We install TensorFlow and set up GPU to make machine learning faster and easier on your computer.

When you want to run machine learning models on your own computer.
When you want to use your computer's graphics card (GPU) to speed up training.
When you are starting a new machine learning project and need the tools ready.
When you want to test if your computer supports TensorFlow with GPU.
When you want to learn how to install software for AI projects.
Syntax
TensorFlow
pip install tensorflow

# To check GPU availability in Python:
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))

Use pip install tensorflow to install the latest TensorFlow version.

Checking GPUs helps confirm if TensorFlow can use your graphics card.

Examples
This command installs TensorFlow with CPU support by default.
TensorFlow
pip install tensorflow
This Python code lists GPUs available to TensorFlow.
TensorFlow
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
GPU setup requires extra steps like installing NVIDIA drivers and CUDA.
TensorFlow
# On Windows, install NVIDIA drivers and CUDA toolkit before TensorFlow GPU
# Then install tensorflow with GPU support (usually same pip install tensorflow)
Sample Model

This program checks TensorFlow installation, lists GPUs, and runs a simple test.

TensorFlow
import tensorflow as tf

# Check TensorFlow version
print('TensorFlow version:', tf.__version__)

# List available GPUs
gpus = tf.config.list_physical_devices('GPU')
print('GPUs found:', gpus)

# Simple test: create a constant and print it
hello = tf.constant('Hello TensorFlow')
print(hello.numpy().decode())
OutputSuccess
Important Notes

GPU support requires compatible NVIDIA GPU, drivers, CUDA, and cuDNN installed.

TensorFlow 2.x includes GPU support in the same package; no separate install needed.

If no GPUs show up, TensorFlow will run on CPU only, which is slower but still works.

Summary

Install TensorFlow using pip install tensorflow.

Check GPU availability with tf.config.list_physical_devices('GPU').

GPU setup speeds up training but needs extra drivers and CUDA installed.