我试图在gpu上使用keras运行autoencoder_layers.py,但是我得到了这个错误

时间:2017-02-20 12:36:38

标签: python neural-network gpu keras autoencoder

autoencoder_layers.py github code

import theano
from keras import backend as K
from keras.backend.theano_backend import _on_gpu
from keras.layers.convolutional import Convolution2D, UpSampling2D
from keras.layers.core import Dense, Layer
from theano import tensor as T
from theano.sandbox.cuda import dnn

但是我收到了这个错误:

 /home/hoda/anaconda2/bin/python /home/hoda/Downloads/keras-convautoencoder-master/autoencoder_layers.py
Using gpu device 0: GeForce GTX 970M (CNMeM is disabled, cuDNN not available)
Using Theano backend.
Traceback (most recent call last):
  File "/home/hoda/Downloads/keras-convautoencoder-master/autoencoder_layers.py", line 3, in <module>
    from keras.backend.theano_backend import _on_gpu
ImportError: cannot import name _on_gpu

我该如何解决?

1 个答案:

答案 0 :(得分:0)

评论专栏from keras.backend.theano_backend import _on_gpu并将_on_gpu定义为:

def _on_gpu():
    return theano.config.device[:3] == 'gpu'

它会修复你的错误。