Tensorflow 2.5 with GPU device (Python 3.9, Cuda 11.2.2 , Cudnn 8.1.1) Conda environment - Windows 10

I want to share the procedure to work with your GPU with the new stable version of tensorflow 2.5 in case someone is having problems with the update.

I have noticed an improvement in training time.

According to official information
https://github.com/tensorflow/tensorflow/releases

Procedure:

  1. Install Anaconda with Python 3.9
    source: https://docs.conda.io/en/latest/miniconda.html

  2. Install the latest version of your GPU driver.

  3. Install Cuda Toolkit 11.2.2
    source: https://developer.nvidia.com/cuda-toolkit-archive

  4. Download Cudnn 8.1.1
    source: https://developer.nvidia.com/rdp/cudnn-archive

Now just copy the files inside from each Cudnn folder and paste into your Cuda folder, follow this example.
source: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-windows

A. Copy \cuda\bin\cudnn*.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin.
B. Copy \cuda\include\cudnn*.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include.
C. Copy \cuda\lib\x64\cudnn*.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib\x64.

  1. Go to your environment variables, Under “System Variables” click on “New” and create the CUDA PATH
    detail:

  2. Create a new conda environment

conda create --name TF-2.5 python=3.9
conda activate TF-2.5

  1. install tensorflow and libraries

pip install tensorflow
pip install tensorflow-datasets
pip install tensorflow-hub
pip install jupyter
pip install numpy
pip install matplotlib
pip install pandas

if you need to use jupyter notebook with the new version of python and tensorflow (very important)

conda install -c conda-forge ipykernel

  1. Register your environment

python -m ipykernel install --user --name TF-2.5 --display-name “Python 3.9 (Tensorflow 2.5)”

  1. Testing your environment

jupyter notebook

detail:

that’s all works completely fine for me.

Regards.

Ricardo.

10 Likes

Thanks for sharing, Ricardo. Just to confirm, is this Windows 10 21H1 or another version of Windows?

2 Likes

Hi Yarri, Your welcome! yes it’s that version.

Screenshot 2021-05-26 150238

Regards, Ricardo.

1 Like

Hi, Ricardo.
from what folder conda should be run ?
When I run it from the default folder of cmd, error happens:

C:\WINDOWS\system32>conda create --name TF-2.5 python=3.9
‘conda’ is not recognized as an internal or external command,
operable program or batch file.
Thanks in advance.

1 Like

Hi Sasha, Because you have to create the environment from the Anaconda Prompt (miniconda3) not from cmd.

Regards, Ricardo

1 Like

Thank you very much, Ricardo.
What application corresponds to the Anaconda Prompt ?
I could not find it in the folders seemed relevant:
C:\Users\User\miniconda3 ;
C:\Users\User\miniconda3\Scripts
?

1 Like

just type ‘Anaconda Prompt’ in windows search

source: https://docs.anaconda.com/anaconda/install/verify-install/

1 Like

Thanks a lot, Ricardo. Now it works perfectly!

2 Likes

Hi!

I cant use my GPU with tensorflow 2.4.0!
I have CUDA 11.0 with 8.0.4 compatible for cuda 11,
all works in python with interpreter (Conda python 3.7.6 with virtual env)

When process image it’s too slow! The GPU isn’t used… why??? What’s wrong? I lost 4 days to find the error… but all .DLL are loaded successfully, i can’t see any error

I show you my screenshot…

https://ibb.co/mFTzN9h
https://ibb.co/XLXbb2y
https ibb co /LpHtMwf (complete this link to view i can max put 2 link in this post)

This procedure works good with Tensorflow 2.6 just keep following the instructions.

Hi Ricardo . I followed the steps but it tells me that I don’t have a graphics card and I have an rtx 3060.

Python_version 3.9.16 (main, Jan 11 2023, 16:16:36) [MSC v.1916 64 bit (AMD64)]
Tensorflow GPU version: 2.11.0
Keras version: 2.11.0
Hub version: 0.12.0
TF Datasets version: 4.8.2
GPUs Available: 0

According to the current installation guide, TensorFlow support for GPUs under Windows ended with version 2.10. I’ve been able to use get around it by running my TensorFlow environment from a Docker image based on tensorflow/tensorflow:latest-gpu-jupyter.