Skip to content

Instantly share code, notes, and snippets.

@cpmpercussion
Created November 4, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpmpercussion/250c37f79173f87e148fa076641b1af8 to your computer and use it in GitHub Desktop.
Save cpmpercussion/250c37f79173f87e148fa076641b1af8 to your computer and use it in GitHub Desktop.
get visible GPUs with Tensorflow
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
get_available_gpus()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment