Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError «You are trying to use the old GPU back-end» when importing keras

I'm using Keras with the Theano backend on Ubuntu 16.04. My setup has been working without issues, however, all of a sudden I get the following error when I import Keras (import keras):

ValueError: You are trying to use the old GPU back-end. It was removed from Theano. Use device=cuda* now. See https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29 for more information.

How do I resolve this?

like image 618
Tshilidzi Mudau Avatar asked Jun 26 '17 17:06

Tshilidzi Mudau


2 Answers

You should change (or add) your environmental variable called THEANO_FLAGS. If you set the variable so that it contains device=cuda instead of device=gpu the error will be gone.

Also set the floating point precision to float32 when working on the GPU as that is usually much faster (THEANO_FLAGS='device=cuda,floatX=float32').

More info on this variable can be found here and here.

like image 63
Wilmar van Ommeren Avatar answered Oct 02 '22 12:10

Wilmar van Ommeren


go to .theanorc file and change device=gpu to device=cuda

like image 27
chaymae bentaleb Avatar answered Oct 02 '22 13:10

chaymae bentaleb