7
$\begingroup$

I use Keras-Tensorflow combo installed with CPU option (it was said to be more robust), but now I'd like to try it with GPU-version. Is there a convenient way to switch? Or shall I re-install fully Tensorflow? Is the GPU version reliable?

$\endgroup$
  • $\begingroup$ I've installed TF version for GPU and doesn't work. I've to wrtie any command line on my code for using GPU? $\endgroup$ – Villuck Mar 28 '18 at 9:15
6
$\begingroup$

I suggest reinstalling the GPU version of Tensorflow, although you can install both version of Tensorflow via virtualenv. GPU version of Tensorflow supports CPU computation, you can switch to CPU easily:

with device('/cpu:0'):
    # your code here

I have been using GPU version of Tensorflow on my Tesla K80 for a few months, it works like a charm. Feel free to have a try!

$\endgroup$
2
$\begingroup$

You would first have to uninstall tensorflow and after that install tensorflow-gpu. After that run your code and it would run on GPU provided you have installed gpu libraries such as CUDA and cuDNN.

$\endgroup$
1
$\begingroup$

Once you installed the GPU version of Tensorflow, you don't have anything to do in Keras. As written in the Keras documentation, "If you are running on the TensorFlow backend, your code will automatically run on GPU if any available GPU is detected."

And if you want to check that the GPU is correctly detected, start your script with:

import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

The standard output should not show any error and print the name of the GPU. If so, you are ready to run Keras and Tensorflow in GPU mode.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.