Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
→ 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.

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:
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.
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.


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.
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.

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.

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

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.

Now, activete your Miniconda environment with conda activate your_env_name
conda activate tensorflow-gpu
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 tensorflow(2.10)
python -m pip install "tensorflow==2.10"

Install specific numpy version(1.26.4).
pip install numpy==1.21.6

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')]
"""

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