Skip to content

Instantly share code, notes, and snippets.

@sanketsudake
Created May 29, 2018 05:29
Show Gist options
  • Save sanketsudake/def814cdef4201693acb0fbfa6cf1ded to your computer and use it in GitHub Desktop.
Save sanketsudake/def814cdef4201693acb0fbfa6cf1ded to your computer and use it in GitHub Desktop.
Get devices available for Tensorflow Computations
from tensorflow.python.client import device_lib
def get_available_devices():
"""
>>> get_available_devices()
['/device:CPU:0']
"""
devices_info = device_lib.list_local_devices()
return [dev.name for dev in devices_info]
if __name__ == '__main__':
print(get_available_devices())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment