【问题标题】:regarding setting up Keras with Theano on GPU关于在 GPU 上使用 Theano 设置 Keras
【发布时间】:2017-03-14 23:14:35
【问题描述】:

我一直按照setting up keras on GPU 的说明进行操作。这就是我按照方法3的建议所做的。

import theano
theano.config.device = 'gpu'
theano.config.floatX = 'float32'

但是,我收到以下错误消息

Using Theano backend.
Traceback (most recent call last):
File "train.py", line 17, in 
theano.config.device = 'gpu'
File "/devl/geophys/dplearn/tensorflow/tf_0.12/lib/python3.4/site-     
packages/theano/configparser.py", line 338, in set

"Can't change the value of this config parameter "

Exception: Can't change the value of this config parameter after initialization!

【问题讨论】:

  • 你可以在调用python时尝试这样做:THEANO_FLAGS=device=gpu,floatX=float32 python my_program.py
  • 或者你可以在home 目录中创建一个 .theanorc 文件。另外请将“gpu”更改为“gpu0”或“gpu1”,看看会发生什么。

标签: theano keras


【解决方案1】:

问题实际上在于,当您使用 TheanoGPU 时 - 在加载包时,它正在加载和编译一些非 Python 函数(例如来自 CUDA)。这就是为什么更改此选项会导致异常 - 在预编译代码中更改此选项是不可能的。要设置此设置,您需要在路径中的 THEANO_FLAGS.theanorc 文件中更改它们。

【讨论】:

  • 嗨,Marcin,谢谢。在我看来,我在 /hom/ 下找不到 theanorc 或 theanorc.txt 是否意味着我必须创建它?具体来说,我应该创建哪个文件,.theanorc 还是 .theanorc.txt?
  • 你使用哪个“操作系统”?
  • 嗨 Marcin,我使用的是 linux,我在主目录下创建了 .theanorc。看起来它删除了错误消息。但是,它给出了一些与 GPU 相关的警告消息。我在另一个线程中问它。
  • 嗨,Marcin,这是我与此问题相关的另一篇文章的链接stackoverflow.com/questions/42816217/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-12
  • 2017-03-12
  • 2013-08-12
  • 2017-05-13
  • 2018-07-18
  • 2018-11-11
相关资源
最近更新 更多