How to force Keras with TensorFlow to use the GPU in R

Viewed 5651

I followed the Tensorflow and Keras installation instructions for R. I have Keras (python3 on Ubuntu 16.04) and it refuses to run on my GPU. I've tried just uninstalling and reinstalling using install_keras(tensorflow = "gpu") and it will still only run on the CPU.

Is there anyway I can check the configurations to see if it is configured to run on the CPU or GPU?

Can I force it to run on the GPU?

enter image description here enter image description here enter image description here

1 Answers

Your tensorflow GPU installation failed because otherwise keras would try to start the computation by default on the GPU. You have to follow exactly the GPU install instructions for tf and you require the exact CUDA and cuDNN versions:

  1. Check if you installed CUDA 9.0 and cuDNN > 7.2 (follow the install instructions here)
  2. Reinstall keras with install_keras(tensorflow = "gpu")
  3. You can list the devices with:

    library(keras) k = backend() sess = k$get_session() sess$list_devices()

Related