Can I run Keras model on gpu ?

Can I run Keras model on gpu ?

Asked on December 19, 2018 in Tensorflow.
Add Comment

  • 2 Answer(s)

    It is possible to run Keras model on gpu. For that just check the below things.

    • System should have GPU
    • Check if your system installed the GPU version of tensorflow
    • You have installed CUDA installation instructions
    • Check whether tensorflow is running with GPU.
    sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

    Or, try this

    from tensorflow.python.client import device_lib


      name: "/cpu:0"device_type: "CPU",
      name: "/gpu:0"device_type: "GPU"

    After Finishing this your system will run on GPU.

    Verify that Keras model is using GPU:

    from keras import backend as K
    Answered on December 19, 2018.
    Add Comment

          First install TensorFlow for GPU. And add the below block after importing keras. In this it had an 56 core CPU, and 1 GPU.

    import keras
    config = tf.ConfigProto( device_count = {'GPU': 1 , 'CPU': 56} ) 
    sess = tf.Session(config=config) 

          This usage enforces to maximum limits. Hence decrease the CPU and GPU consumption values.

    Answered on December 19, 2018.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.