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

Malgo picture Malgo · Dec 10, 2019 · Viewed 16.5k times · Source

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?

Answer

Malgo picture Malgo · Dec 10, 2019

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.