我试图运行在GPU上使用keras autoencoder

编程入门 行业动态 更新时间:2024-10-25 16:26:26
我试图运行在GPU上使用keras autoencoder_layers.py,但我得到这个错误(I am trying to run autoencoder_layers.py using keras on gpu but i get this error)

autoencoder_layers.py github代码

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

我该如何解决它?

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

but I get this error:

/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

how can I fix it?

最满意答案

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

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

它会解决你的错误。

Comment the line from keras.backend.theano_backend import _on_gpu and define _on_gpu as:

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

It will fix your error.

更多推荐

本文发布于:2023-07-05 14:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1038470.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GPU   keras   autoencoder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!