GPU not captured by TensorFlow

Viewed 1077

I installed tensorflow using pip install tensorflow within Anaconda virtual environment on Windows.

I tried to test whether GPU is enabled, and type

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

and got

Num GPUs Available:  0

My system does have CUDA and CUDNN enabled, as I do not have a problem installing PyTorch GPU version. How do I enable GPU for TensorFlow?

2 Answers

At first, uninstall tensorflow using,

pip uninstall tensorflow

Install tensorflow-gpu version,

pip install tensorflow-gpu==2.2.0 

If using pip did't work you can try with conda install command.

conda install -c anaconda tensorflow-gpu 

This will automatically install CUDA & cuDNN. Hope this will solve your issue.

Remove the cpu version tensorflow using pip uninstall tensorflow and install the gpu version of the tensorflow, pip install tensorflow-gpu.

You can check this tutorial link as well.

It can be summarized by the following steps:

  1. Uninstall your old tensorflow
  2. Install tensorflow-gpu pip install tensorflow-gpu
  3. Install Nvidia Graphics Card & Drivers (you probably already have)
  4. Download & Install CUDA
  5. Download & Install cuDNN
  6. Verify with your program.
Related