How to Solve NameError: name 'device_lib' is not defined -- tensorflow

Solution: Import the 'device_lib' module

To Solve the error, add the following line to the top of your code.

from tensorflow.python.client import device_lib

 

For more information:
Python tensorflow device_lib