Search code examples
pythontensorflowenvironment-variablesgpu

Tensorflow can't find available GPUs (win11)


I have a pretty common issue: tensorflow framework can't recognize available GPUs on my laptop. When i try to list available GPUs in VS Code using Python (v3.11.0):

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
print("Built with CUDA:", tf.test.is_built_with_cuda())
print("Built with GPU device support:", tf.test.is_built_with_gpu_support())

output: 
Num GPUs Available: 0
Built with CUDA: False
Built with GPU device support: False

Laptop specs:

  • System: Windows 11 Pro (23H2)
  • GPU: GeForce GTX 1660Ti 6Gb
  • CPU: Intel Core i7 9750h

What i've done before:

  • Download Tensorflow framework (2.16.1) via pip
pip install tensorflow[and-cuda]
  • Updated NVIDIA driver (v560.70)
  • Downloaded NVIDIA GPU Computing Toolkit (CUDA v12.3)
  • Downloaded cuDNN driver (v8.9) and paste files from bin, lib, include to appropriate folders in CUDA root path
  • Manually added environment variables in Windows system properties (Path, CUDA_PATH, CUDA_HOME) Env variables config
  • Added custom graphic settings to VS Code IDE Settings -> System -> Display -> Graphics
  • Checked: does the system detect the video card using cmd: nvidia-smi terminal output
  • Checked drivers compatibility (i guess everything ok)
  • Restart system

Hope we'll find the solution :), if you have specific questions, please ask


Solution

  • TensorFlow 2.10 was the last TensorFlow release that supported GPUs on native-Windows. If you need to run on a Windows system with a newer version of TensorFlow you'll need to set up WSL2. Here's the user guide from Nvidia on setting up WSL2 for Cuda: https://docs.nvidia.com/cuda/wsl-user-guide/index.html