2

I have tensorflow-gpu version 2.2.0 installed with Anaconda in python 3.7.4, but my code always runs on CPU and It's not able to detect my GPU.

physical_devices= tf.config.experimental.list_physical_devices('GPU')
print(len(physical_devices))
>>> 0

When I run this:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

I get:

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 6159543114609950707
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 4043157374881641271
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 1519736160969870434
physical_device_desc: "device: XLA_GPU device"
]

The XLA_GPU:0 corresponds to the integrated graphics that runs on CPU, because I have tested running my code under with tf.device('/GPU:0'): and Task Manager shows only CPU usage.

I checked in my NVIDIA Control Panel -> System Information -> Components and under 3D Settings I have NVCUDA64.dll described as NVIDIA CUDA 11.0.208 Driver.

Up to this moment I haven't tried reinstalled tensorflow-gpu, expecting there could be something else that has to be done before.

2
  • I am not sure, but it could be that tf 2.2 doesn't support your current CUDA version. Though, I thought CUDA would be backwards compatible. Commented Aug 15, 2020 at 4:48
  • I downgraded to 10.1 and got the corresponding cuDNN version but still doesn't work. Any ideas? Commented Aug 16, 2020 at 16:32

4 Answers 4

3

My own answer. Finally it worked:

I had to download CUDA 10.1 and then cuDNN 7.6.5 for that version.

Thanks to @Gerry P and @Richard X

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you all, I had the same issue, by installing cuDNN it works!
2

I do not believe 11.0 will work with tensorflow. You need 10.1. I have an RTX2070 and the driver version that work for that is 432.00. Go to the NVIDIA site and try to find a 10.1 compatible driver and install it. IF you used CONDA to install tensorflow then it should have installed the 10.1 CUDA toolkit and the compatible version of Cudnn.

4 Comments

I followed the instructions and installed CUDA 10.1. Then I looked for the respective cuDNN for that version and followed the installing instructions, but that doesn't seem to be working either.
I think you need to change you GPU card DRIVER to a driver compatible with 10.1.
Do you know what card driver version should I install?My current is 451.67
it depends om what GPU card you have. Mine is an RTX2070 and the driver version is 432.00
2

I recently installed tensorflow 2.7 and it worked fine. Here is my configuration: CUDA: 11.5, CUDNN: 8.3, TENSORFLOW: 2.7, PYTHON: 3.9.9, GPU: NVIDIA GTX 1060, DRIVER VERSION: 497.29

I did not use Conda (even though it is very convenient but it results in a lot of version conflicts). I installed everything manually on Windows 10 like below. So, if anyone looking for instructions in or after Jan 2022:

  1. Install python b/w 3.90 - 3.9.9 (https://www.python.org/downloads/release/python-399/)
  2. Install cuda tool kit (Check compatibility with your GPU) (https://developer.nvidia.com/cuda-toolkit-archive)
  3. Install cudnn and make sure it is compatible with the cuda version installed above (https://developer.nvidia.com/rdp/cudnn-archive)

*Note: don't forget to install zlib when following instructions from the link above (https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-zlib-windows)

  1. Make sure the bin of both cuda and cudnn are on the PATH (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\bin), (C:\Program Files\NVIDIA GPU Computing Toolkit\cudnn-windows-x86_64-8.3.1.22_cuda11.5-archive\bin)
  2. Install tensorflow (https://www.tensorflow.org/install/gpu) Use pip3 when installing for python3+
  3. If you want to create Jupyter notebooks then install jupyter "pip3 install jupyterlab" (https://jupyter.org/install)
  4. Finally, restart your machine or atleast restart the shell
  5. Run the following from python REPL, you should get 1 or more
import tensorflow as tf 

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

Comments

0

Check Tensorflow's documentation for matching version with CUDA and cuDNN:

https://www.tensorflow.org/install/source#gpu

Make sure you get them correct. Otherwise they will not work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.