Created
May 29, 2018 05:29
-
-
Save sanketsudake/def814cdef4201693acb0fbfa6cf1ded to your computer and use it in GitHub Desktop.
Get devices available for Tensorflow Computations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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