【问题标题】:I am trying to run autoencoder_layers.py using keras on gpu but i get this error我正在尝试在 gpu 上使用 keras 运行 autoencoder_layers.py 但我收到此错误
【发布时间】:2017-02-20 12:36:37
【问题描述】:

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

我该如何解决?

【问题讨论】:

    标签: python neural-network gpu keras autoencoder


    【解决方案1】:

    注释from keras.backend.theano_backend import _on_gpu 行并将_on_gpu 定义为:

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

    它会修复你的错误。

    【讨论】:

      猜你喜欢
      • 2021-02-16
      • 2020-01-28
      • 2019-09-23
      • 2019-09-08
      • 2019-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-08
      相关资源
      最近更新 更多