Installing TensorFlow and PyTorch is an essential skill for anyone getting into machine learning and deep learning. These two libraries provide powerful tools for building models and underpin research and real-world AI applications. This guide walks you through installing both on Windows, Linux and macOS.
Quick answer: Install TensorFlow and PyTorch in a virtual environment (venv or conda) to avoid conflicts. (1) Install Python 3.x and pip; (2) create an environment: python -m venv ml && source ml/bin/activate (Windows: ml\Scripts\activate); (3) TensorFlow: pip install tensorflow (recent versions include GPU support on Linux; on Windows use WSL2 for GPU); (4) PyTorch: copy the exact command for your CUDA version from pytorch.org, for example CPU only: pip install torch torchvision torchaudio; (5) check the GPU: import tensorflow as tf; tf.config.list_physical_devices('GPU') and import torch; torch.cuda.is_available(). GPU use requires an NVIDIA driver plus compatible CUDA/cuDNN; the easiest route is conda or an official Docker image.
Installing TensorFlow
TensorFlow can be installed in several ways. First, prepare your development environment.
Prepare the environment
Make sure Python and pip are installed. If not, download Python from the official website. Check that your Python version is supported by the TensorFlow release you want.
Install TensorFlow with pip
Open a terminal (or Command Prompt on Windows), activate your virtual environment and run:
pip install tensorflowWait for the installation to finish and TensorFlow is ready to use.
Install TensorFlow with Anaconda
If you prefer Anaconda, create an environment with Anaconda Navigator or the command line, then install TensorFlow with pip inside it (TensorFlow officially publishes pip packages):
conda create -n tensorflow python=3.11
conda activate tensorflow
pip install tensorflowTensorFlow on Windows
On Windows the process is the same. Check that your Python version is compatible with TensorFlow. Native Windows builds run on the CPU; for GPU acceleration, use WSL2.
TensorFlow on Linux
On Linux, use pip or Anaconda. Make sure pip is installed:
sudo apt install python3-pip python3-venvThen install TensorFlow with the pip command above (use pip install tensorflow[and-cuda] for NVIDIA GPU support).
TensorFlow on macOS
On macOS the process is similar. Install the Xcode Command Line Tools so terminal tools work smoothly; on Apple Silicon, the tensorflow-metal plugin adds GPU acceleration.
Verify TensorFlow
Start Python and run:
import tensorflow as tf
print(tf.__version__)If the version is shown, TensorFlow is installed correctly.
Installing PyTorch
Like TensorFlow, PyTorch is straightforward to install.
Install PyTorch with pip
Open a terminal and run (CPU-only example):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpuFor GPU support, use the command generated on pytorch.org for your CUDA version.
Install PyTorch with Anaconda
Recent PyTorch releases are distributed mainly through pip; inside a conda environment, use the pip command from pytorch.org. Older guides used:
conda install pytorch torchvision torchaudio cpuonly -c pytorchPyTorch on Windows
On Windows, use the pip steps above and make sure you choose the build that matches your system and GPU.
PyTorch on Linux
On Linux, besides pip, you can choose builds for specific CUDA versions to use GPU computing.
PyTorch on macOS
On macOS, install with pip; on Apple Silicon, PyTorch can use the GPU through the MPS backend.
Verify PyTorch
Start Python and run:
import torch
print(torch.__version__)If the version is shown, PyTorch is installed correctly.
Common installation problems
You may run into missing libraries, version conflicts or CUDA issues with GPU builds. Here is how to handle them:
- Missing libraries: make sure all required system libraries (for example the Microsoft Visual C++ Redistributable on Windows) are installed.
- Version conflicts: usually caused by incompatible packages; use a fresh virtual environment per project and check installed versions with
pip list. - CUDA problems: if you use a GPU, make sure the NVIDIA driver and CUDA version are compatible with your PyTorch or TensorFlow release.
Conclusion: start your deep learning journey
Installing TensorFlow and PyTorch is the first step into deep learning. Follow the steps in this guide and you can start researching or building your own projects. For GPU workstations or AI infrastructure for your business, contact IT Systems at hotline 028.3995.03.59 or contact@itsystems.com.vn.
FAQ
Do TensorFlow and PyTorch need an NVIDIA GPU?
No, both run on CPU. An NVIDIA GPU with CUDA speeds training greatly; Apple Silicon Macs use Apple’s own acceleration.
Should I install them in a virtual environment?
Yes. Use venv or conda per project to avoid Python, CUDA and library version conflicts.
How do I check that PyTorch sees the GPU?
In Python run import torch then torch.cuda.is_available(); for TensorFlow use tf.config.list_physical_devices(‘GPU’).
Need someone to run your servers, NAS and systems?
IT Systems manages servers, NAS, cloud, backup and user accounts on a schedule, with a monthly operations report.




