Issue
Is there any way to check if the Keras framework is using the GPU or CPU for training the model?
I am training my model on GPU using keras but its so slow that I'm unsure if it's using CPU or GPU for training.
Solution
First lets make sure tensorflow is detecting your GPU. Run the code below. If number of GPUs=0 it is not detecting your GPU. For tensorflow to use the GPU you need to have the Cuda toolkit and Cudnn installed. If no GPU is detected and you are using Anaconda reinstall tensorflow with Conda. It automatically installs the toolkit and Cudnn. Pip does not install these when you use it to install tensorflow.
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
print(tf.__version__)
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
tf.test.is_gpu_available()
!python --version
Answered By - Gerry P
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.