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

3

16

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?

Elmerelmina answered 26/6, 2017 at 17:35 Comment(2)
It is probably the environmental variable THEANO_FLAGS. If you set the variable so that it contains device=cuda instead of device=gpu it will be fixed.Topdress
hi @WilmarvanOmmeren, I just tried this now, and it worked. If you put your comment as an answer I will mark it as the correct answer. Thanks .Elmerelmina
T
21

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.

Topdress answered 27/6, 2017 at 5:40 Comment(1)
export THEANO_FLAGS=mode=FAST_RUN,device=cuda,floatX=float32Calorie
A
2

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

Aviary answered 15/8, 2022 at 19:6 Comment(0)
P
-2

for me no gpu,use cpu,work :

export THEANO_FLAGS='mode=FAST_RUN,device=cpu,floatX=float32'
Protolanguage answered 1/8, 2018 at 8:32 Comment(1)
Could you elaborate a bit on what this means exactly and how it answers the question?Nore

© 2022 - 2024 — McMap. All rights reserved.