'AttributeError: module 'tensorflow_core._api.v2.config' has no attribute 'list_physical_devices'

Am using Tensorflow 2.0 on Ubuntu 18.04. On running

tf.config.list_physical_devices('GPU')

I get the above error. What is the workaround for this?



Solution 1:[1]

Run tf.config.experimental.list_physical_devices('GPU') to see all the GPUs

or

run tf.config.experimental.list_physical_devices(device_type=None) to see all the devices

You can also use tf.test.is_gpu_available(). It says True if it detects the available gpu.

Solution 2:[2]

The updated answer should be for Tensorflow 2.0 is tf.config.list_physical_devices('GPU')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 shanecp