Tensorflow / CUDA: GPU not detected

Question:

I have two Windows 11 laptops with NVIDIA GeForce RTX 3060 GPUs, which I want to run Tensorflow on.

If that matters, both laptops are Lenovo Legion 5 laptops with "GPU Working Mode" set to "Hybrid-Auto Mode".

The first laptop has the following setup:

Python     3.10.7
Tensorflow 2.9.1
CUDA       11.2.0
cuDNN      8.1.1

CPU        AMD Ryzen 7 6800H
GPU0       NVIDIA GeForce RTX 3060
GPU1       AMD Radeon Graphics

The second laptop has the following setup:

Python     3.10.9 Virtual Environment
Tensorflow 2.11.0
CUDA       11.2.2
cuDNN      8.1.1

CPU        Intel Core i7 12th Gen 12700H
GPU0       Intel Iris Xe
GPU1       NVIDIA GeForce RTX 3060

CUDA and cuDNN were installed as per this video: https://www.youtube.com/watch?v=hHWkvEcDBO0 (except for the conda part).

On the first laptop, everything works fine. But on the second, when executing tf.config.list_physical_devices('GPU'), I get an empty list.

I have tried to set the CUDA_VISIBLE_DEVICES variable to "0" as some people mentioned on other posts, but it didn’t work.

I also tried the same as the second laptop on a third one, and got the same problem.

What could be the problem?

Asked By: Chris Rahmé

||

Answers:

Actually the problem is that you are using Windows, TensorFlow 2.11 and newer versions do not have anymore native support for GPUs on Windows, see from the TensorFlow website:

Caution: TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11, you will need to install TensorFlow in WSL2, or install tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin

From TensorFlow 2.11 onwards, the only way to get GPU support on Windows is to use WSL2.

Answered By: Dr. Snoopy
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.