Skip to content

Instantly share code, notes, and snippets.

@cozek
Created October 7, 2019 06:15
Show Gist options
  • Save cozek/e47ce8e29b229fb79e1eb58ad36f1645 to your computer and use it in GitHub Desktop.
Save cozek/e47ce8e29b229fb79e1eb58ad36f1645 to your computer and use it in GitHub Desktop.
Check if keras is using the GPU
# https://stackoverflow.com/questions/44544766/how-do-i-check-if-keras-is-using-gpu-version-of-tensorflow/44547144
# confirm TensorFlow sees the GPU
from tensorflow.python.client import device_lib
assert 'GPU' in str(device_lib.list_local_devices())
# print(device_lib.list_local_devices())
# confirm Keras sees the GPU
from keras import backend
assert len(backend.tensorflow_backend._get_available_gpus()) > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment