[Python] Can't detect GPU with cuDNN 8.6 and CUDA 11.8

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

  1. Stack

    Stack Membro Participativo

    I am trying to use TensorFlow with my NVIDIA GeForce RTX 4090 GPU on Windows 11. I installed CUDA 11.8 and cuDNN 8.6 but TensorFlow fails to detect the GPU and computations are performed on the CPU.

    • Latest NVIDIA drivers were installed. Verified using nvidia-smi.
    • Downloaded and installed CUDA Toolkit 11.8 from the NVIDIA website.
    • Downloaded and installed cuDNN 8.6 ensuring the files were copied to the CUDA directory.
    • Initially installed tensorflow-gpu but faced issues, so I switched to TensorFlow since GPU support is included by default in TensorFlow 2.x.
    • Verified that CUDA and cuDNN were correctly installed and functional using the CUDA samples provided by NVIDIA.
    • Ensured the environment variables for CUDA and cuDNN were set correctly in the system PATH.

    Python code for verification:

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

    # Simple matrix multiplication to test computation
    a = tf.constant([[1.0, 2.0], [3.0, 4.0]])
    b = tf.constant([[1.0, 1.0], [1.0, 1.0]])
    c = tf.matmul(a, b)
    print("Result of matrix multiplication:\n", c)


    Output:

    No GPU found.
    2024-07-31 14:23:01.757763: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
    To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX AVX2 AVX512F AVX512_VNNI AVX512_BF16 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
    Result of matrix multiplication:
    tf.Tensor(
    [[1. 3.]
    [3. 7.]], shape=(2, 2), dtype=float32)


    TensorFlow still fails to detect the GPU.

    Continue reading...

Compartilhe esta Página