Installation Guide for a GPU Supported Tensorflow Environment

→ How to create a GPU-supported TensorFlow environment using Miniconda.

If you are interested in Deep Learning, it is important to have GPU-supported PyTorch and TensorFlow environments. Imagine you want to train a CNN network that classifies dog species, you need to process images, make calculations between pixels, perform matrix operations and more. GPU allows you to do all these tasks in parallel and approximately 20x faster than a CPU. In this article, I will show you how to set up a GPU-supported TensorFlow environment.

Installation Guide for a GPU-Supported TensorFlow Environment

You only need an Nvidia GPU to follow this article. It can be a GTX or RTX series; it doesn’t matter. For example, my GPU is GTX 1660ti Max-Q, it must have been 10 years since this GPU was manufactured; but no problem, you can still use old GPUs for creating a GPU-supported TensorFlow environment.

There are four main steps for creating a GPU supported Tensorflow Miniconda environment:

  1. Check GPU drivers
  2. Install Miniconda
  3. Create a Miniconda Environment
  4. Install Tensorflow with GPU support using pip

By the way, there is an official installation documentation(link) published by TensorFlow, but it might be complex. I will only show you the necessary parts from that documentation.

1. Check GPU drivers from terminal

This step is probably not necessary, because most of the time GPU drivers are already installed on your computer. You can check GPU drivers by typing nvidia-smi in the terminal.

nvidia-smi

I created two different environments on two different laptops, and you can see the output of the nvidia-smi command for both.

CUDA version 13.0 on a Laptop with an GTX 1660ti Max-Q GPU
CUDA version 12.9 on a Laptop with an RTX 3060 GPU

If you get any errors you can install GPU drivers from Nvidia GeForce Experience(link). Explanations are very clear, you can install drivers in a few minutes.

2. Install Miniconda

Miniconda is a light version of Anaconda. It allows you to create isolated environments. You can install Miniconda from this link; the executable (.exe) file is around 90 MB.

Installing Miniconda for creating a GPU-supported TensorFlow environment

After the executable file is downloaded, open it. Accept the agreements, and when it asks if you want to add Miniconda to the PATH, uncheck it, because it might create a conflict with other installations.

Installing Miniconda for creating a GPU-supported TensorFlow environment

After the installation is finished, type Anaconda Prompt in your Windows search bar.

Anaconda for creating a GPU-supported TensorFlow environment

3. Create a Miniconda Environment

Now it is time to create an environment. You can name it whatever you want. I named it tensorflow-gpu.

conda create --name tensorflow-gpu python=3.9

When you first try to create an environment, you might see some warnings about licenses. Accept these agreements, and then try to create it again.

GPU-supported TensorFlow Miniconda Environment

Now, activete your Miniconda environment with conda activate your_env_name

conda activate  tensorflow-gpu

4. Install Tensorflow with GPU support using pip

I tested it with two different devices, and I found specific versions that work for different CUDA versions.

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
Install cudatoolkit and cudnn

Install tensorflow(2.10)

python -m pip install "tensorflow==2.10"
Install tensorflow with GPU support

Install specific numpy version(1.26.4).

pip install numpy==1.21.6
Install numpy

Now, it is time for testing. You can directly test from the terminal, or create a new Python file and run it in your environment.

import tensorflow as tf

print(tf.config.list_physical_devices("GPU"))

""" 
Output should be: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
"""
GPU-Supported TensorFlow Environment

I also have an article about how to create a GPU-supported PyTorch environment, you can read it.