Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow 2.0 list_physical_devices doesn't detect my GPU

I recently install tensorflow 2.0 on my computer but when I try to run it on my GPU, the function tf.config.experimental.list_physical_devices('GPU') on Jupyter or Vitual Studio Code it returns me a void array. Do you know why ?

My set-up :

Computer : MSI

Processor : Intel(R) Core(TM) i7-8750H CPU @ 2.220GHz

GPU 0 : Intel(R) UHD Graphics 630

GPU : NVIDIA GeForce GTX 1060

Python : Ananconda 3 with Python 3.7

Tensenflow 2.0 installed with pip install tensorflow

My test code :

physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
  tf.config.experimental.set_memory_growth(physical_devices[0], True)

Thanks in advance ! :)

like image 643
Kolopox Avatar asked Oct 15 '22 09:10

Kolopox


1 Answers

Providing the solution here (Answer Section), even though it is present in the Comment Section for the benefit of the community.

Instead of pip install tensorflow, you can try pip3 install --upgrade tensorflow-gpu or just remove tensorflow and then installing "tensorflow-gpu will resolves your issue.

After installation of Tensorflow GPU, you can check GPU as below

physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
  tf.config.experimental.set_memory_growth(physical_devices[0], True)

Output:

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
like image 60
Tensorflow Warrior Avatar answered Oct 20 '22 11:10

Tensorflow Warrior