Tensorflow not detecting GPU

Hello together,

I now lost 3 days of my valuable life trying to get tensorflow to detect and use my GPU to train some neuronal network models and I desperately need help.

I tried uncountable tutorials and forum posts but nothing did work.

I have a MSI GTX 1070 (latest driver)
Windows 10 Pro 64bit
CUDA 11.8.0 (I checked the tf homepage if my versions are compatible, and they should be)
CuDNN 8.6.0
tensorflow 2.12.0
Python 3.10.11

ソースからビルド  |  TensorFlow sais:
tensorflow-2.12.0 python 3.8-3.11 GCC 9.3.1 Bazel 5.3.0 CuDNN 8.6 CUDA 11.8

and I set my system environment variables like I should (adding CUDA and CuDNN paths to “Path”)

I tried seing my GPU with “print(tf.config.list_physical_devices(‘GPU’))” in VSC and Anaconda Prompt and both returned nothing :frowning: Restarting the PC uncountable times didn’t change anything.

I’m really desperate, please help me.

Thanks in advance
Marius

About a year ago I used CUDA in combination with Matlab and it worked just fine, so I know at least that my 1070 is able to work with CUDA.

Hi @Marius, 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. For installing WSL2 please refer to this document. Thank You.

3 Likes

Hi Kiran,
thanks a lot for your response!
Is it possible to uninstall my version of tf and just install tf 2.10? (And the compatible versions of cuda und cudnn to harmonize with tf 2.10)

1 Like

Hi @Marius , Yes it is possible to uninstall tensorflow by using pip unistalll tensorflow and you can install 2.10 version. Thank You.

1 Like

Hi @Kiran_Sai_Ramineni

thanks you very much for your help!
I now run following configuration:

Python 3.10.11, TF 2.10.0, CuDNN 8.1.0.77, CUDA 11.2.0

Tensorflow now does find my GPU:

print(tf.config.list_physical_devices(‘GPU’))


[PhysicalDevice(name=‘/physical_device:GPU:0’, device_type=‘GPU’)]

print("Num GPUs Available: ", len(tf.config.list_physical_devices(‘GPU’)))


Num GPUs Available: 1

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())


[name: “/device:CPU:0”
device_type: “CPU”
memory_limit: 268435456
locality {
}
incarnation: 191322745317478286
xla_global_id: -1
, name: “/device:GPU:0”
device_type: “GPU”
memory_limit: 6957301760
locality {
bus_id: 1
links {
}
}
incarnation: 13611211276137398635
physical_device_desc: “device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1”
xla_global_id: 416903419
]

Do you have any advice/tips on how to find out wether VSC is now really using my GPU or not? To verify wether it just knows that the GPU is there or it’s actually using it? And is it possible to turn it off or on to use the gpu?

Thanks a lot again!
Cheers
Marius

Hi @Marius, As len(tf.config.list_physical_devices(‘GPU’)) display output as 1, i.e 1 GPU was detected by the tensorflow. Thank You.

thank you so much for this information! i spent two days trying to figure out what was wrong :cry: why do the docs say nothing about this…

1 Like

Actually, I struggled with similar issues and now I write this for anyone who still seeks:

Instead of typing “pip install tensorflow” (or “pip install tensorflow”<11"“) I typed “conda install tensorflow” (“conda install tensorflow”<11"” in Windows). Problem was that Anaconda didn’t see tensorflow, since it was installed by pip (don’t ask, I don’t know why).

i used this guide: Tutorial - Install TensorFlow GPU on Windows 10 - Stephane Damolini - MIT Data Scientist & Engineer
besically an user need to install CUDA and cuDNN before install tensorflow gpu and be carefull to install it in anaconda

1 Like

Spent a couple of days with python 3.8 trying to get tflow 2.4 to detect my gpu…and this solution worked in a couple of minutes. Thank you for this!

Hey @Marius
I have done the same things as you. Where should i run these commands to check the availability of the gpu. Also i have 2 gpu’s (GPU-0(512mb) and GPU-1(4gb)). Of these two which one should be working when i train my model.

Is it still possible to install the 2.10 version? How can i do it? pip install tensorflow==2.10?

Can i use tensorflow 2.10 on python 3.11?

Hi John, what did you use?

Hi @onehit1499, As per the test built configuration Tensorflow 2.10 Version supports python 3.7-3.10. For installation you can use pip install tensorflow==2.10. Thank You.

hey @Kiran_Sai_Ramineni , Sorry for asking this late. As of right now i have tensor flow 2.12 installed in an virtual environment and i have cuda 11.8 and cudnn 8.6. How do i install cuda 11.2 , if there’s no option for windows 11

hi @Kiran_Sai_Ramineni, l also have the same problem, that tensorflow can’t find my gpu. l have tensorflow 2.15.0, python 3.10, cuda 12.4.0 and cudnn 9.0.0. l really don’t understand whats wrong and l can’t find the apropriate version to be compatible… l also have the cuda and cudnn in the path variable.

Hi @kostas_bouros,Below are the supported versions of CUDA and CUDNN for the tensorflow 2.15.


You can find the list of test build configurations here. You can use pip install tensorflow[and-cuda] command which will automatically install CUDA and CUDNN supported for tensorflow 2.15.

Also note that 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 or tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin. Thank You.

1 Like

it worked!!! thanks a lot!!!