Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New TensorFlow(Compatible for GPU) Not Detecting GPU: CUDA 12.6, cuDNN, and Environment Variables Issues

I'm having trouble getting TensorFlow to recognize my GPU. Despite following several guides, TensorFlow still reports no GPUs available. Here are the details of my setup and the issue:

System Information:

Operating System: Windows 11 Home

GPU: NVIDIA GeForce RTX 4070 Laptop GPU

NVIDIA Driver Version: 560.81

CUDA Version: 12.6

cuDNN Version: 9.3.0

 !nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Fri_Jun_14_16:44:19_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.20
Build cuda_12.6.r12.6/compiler.34431801_0



  !nvidia-smi
Wed Aug 14 09:18:01 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.81                 Driver Version: 560.81         CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4070 ...  WDDM  |   00000000:01:00.0 Off |                  N/A |
| N/A   51C    P3             13W /   55W |       0MiB /   8188MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

    import tensorflow as tf

2024-08-14 09:18:06.027008: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-08-14 09:18:06.960623: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.

gpus = tf.config.list_physical_devices('GPU')

print("Available GPUs: ", gpus)
Available GPUs:  []

I decide to seek help from my old buddy stackoverflow, we got stuck with chatgpt. Thanks to everyone

like image 651
özgür Sanli Avatar asked Sep 01 '25 20:09

özgür Sanli


1 Answers

I guess this note from the TensorFlow documentation sums it up:

GPU support on native-Windows is only available for 2.10 or earlier versions

Below it you also find the compatible combinations of Python, TensorFlow, CUDA and cuDNN.

In case you absolutely need to use Windows, these are the last supported versions:

TensorFlow Python CUDA cuDNN
tensorflow_gpu-2.10.0 3.10 11.2 8.1

As you can see, even if you correctly installed version 2.10 and not the latest version of TensorFlow, your version of CUDA and cuDNN are not supported.

So to make sure you have to correct versions set up, try these steps taken from the documentation for Windows Native:

  1. Install Microsoft Visual C++ Redistributable, in case it is not already installed: https://aka.ms/vs/17/release/vc_redist.x64.exe
  2. Install MiniConda: https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
  3. Create a new conda environment named tf, make sure to keep it activated for the rest of the installation: conda create --name tf python=3.9
  4. Install the correct versions of CUDA and cuDNN: conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
  5. Make sure pip is up to date: pip install --upgrade pip
  6. Install the correct version of TensorFlow: pip install "tensorflow<2.11"
  7. Verify GPU setup: python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If you would like to use the latest version of TensorFlow, you should consinder using WSL2. Take a look here for further information.

like image 82
ntbt Avatar answered Sep 03 '25 19:09

ntbt