[Python] Tensorflow does not detect GPU altough the GPU driver and Cuda are installed

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have an Nvidia GPU (Geforce RTX 3090) and the driver is displayed in Nvidia Control Panel. I also have installed the latest version of Cuda. However, when using the following code in Python with TensorFlow:

    gpus = tf.config.list_physical_devices('GPU')
    if not gpus:
    print("No GPUs detected")
    else:
    print("GPUs detected:")
    for gpu in gpus:
    print(gpu)


    It always shows me, that no GPU is detected. Can you tell me what I have to do in order to make Tensorflow use the GPU?

    EDIT: I am using PyCharm and downloaded Python directly (so I don't use something like Anaconda).

    Update: Here is the nvidia-smi output from the cmd:

    U:\>nvidia-smi
    Wed Jul 12 09:13:40 2023
    +---------------------------------------------------------------------------------------+
    | NVIDIA-SMI 531.14 Driver Version: 531.14 CUDA Version: 12.1 |
    |-----------------------------------------+----------------------+----------------------+
    | GPU Name TCC/WDDM | 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 3090 WDDM | 00000000:65:00.0 On | N/A |
    | 0% 36C P8 13W / 350W| 2085MiB / 24576MiB | 0% Default |
    | | | N/A |
    +-----------------------------------------+----------------------+----------------------+

    +---------------------------------------------------------------------------------------+
    | Processes: |
    | GPU GI CI PID Type Process name GPU Memory |
    | ID ID Usage |
    |=======================================================================================|
    | 0 N/A N/A 3252 C+G ...m Files\Mozilla Firefox\firefox.exe N/A |
    | 0 N/A N/A 4364 C+G ...h2txyewy\InputApp\TextInputHost.exe N/A |
    | 0 N/A N/A 11312 C+G ...soft Office\root\Office16\EXCEL.EXE N/A |
    | 0 N/A N/A 19072 C+G ...5n1h2txyewy\ShellExperienceHost.exe N/A |
    | 0 N/A N/A 21476 C+G ...m Files\Mozilla Firefox\firefox.exe N/A |
    | 0 N/A N/A 23832 C+G ....Search_cw5n1h2txyewy\SearchApp.exe N/A |
    | 0 N/A N/A 24544 C+G ..._8wekyb3d8bbwe\Microsoft.Photos.exe N/A |
    | 0 N/A N/A 25932 C+G ...x64__8wekyb3d8bbwe\ScreenSketch.exe N/A |
    | 0 N/A N/A 33528 C+G ...ekyb3d8bbwe\PhoneExperienceHost.exe N/A |
    | 0 N/A N/A 36580 C+G ...on 2022.3.1\jbr\bin\jcef_helper.exe N/A |
    | 0 N/A N/A 42128 C+G ...cal\Microsoft\OneDrive\OneDrive.exe N/A |
    +---------------------------------------------------------------------------------------+


    Update: I downgraded to tensorflow 2.10 and get some new error messages:"2023-07-15 15:15:23.440924: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2023-07-15 15:15:23.441186: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine."

    Continue reading...

Compartilhe esta Página