使用GPU为Keras设置NO标志

2024-09-29 17:14:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Keras中训练一个没有后端的模型,并使用我的GPU。如果我运行100个图像或20K,我会收到一个错误,从no(看下面)说我没有足够的内存,但我的GPU上有6GB。我使用了来自Keras docs“THEANO_FLAGS=device=gpu,floatX=float32 python my_keras”中的THEANO_标志_脚本.py“问题是我使用了来自stackoverflow(echo-e)的this one\n[global]\nfloatX=float32\n设备=gpu0\n[lib]\ncnmem=0\n”>;~/.theanorc )设置cnmem变量,这样如果使用Keras的标志,它将使用堆栈溢出设置的cnmem。在

我已经将cnmem设置为0.83(它没有立即出错的最高值)和0,没有任何东西有822MB的要求,但我有6GB的视频内存。我确信我做了一些简单的错误,但我找不到任何关于它的信息。在

我在ubuntu14.04上安装了CUDA。我刚刚做了一个Keras MNIST示例,使用“THEANO_FLAGS=device=gpu,floatX=float32 python mnist_传输”_美国有线电视新闻网 ““

MemoryError: Error allocating 822083584 bytes of device memory (out of  memory).
Apply node that caused the error: GpuElemwise{add,no_inplace} (GpuDnnConv{algo='small', inplace=True}.0, GpuReshape{4}.0)
Toposort index: 375
Inputs types: [CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, (True, False, True, True))]
Inputs shapes: [(64, 64, 224, 224), (1, 64, 1, 1)]
Inputs strides: [(3211264, 50176, 224, 1), (0, 1, 0, 0)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[GpuElemwise{Composite{(i0 * (i1 + Abs(i1)))},no_inplace}(CudaNdarrayConstant{[[[[ 0.5]]]]}, GpuElemwise{add,no_inplace}.0), GpuElemwise{Composite{((i0 * i1) + (i0 * i1 * sgn(i2)))}}[(0, 1)](CudaNdarrayConstant{[[[[ 0.5]]]]}, GpuDnnPoolGrad{mode='max'}.0, GpuElemwise{add,no_inplace}.0)]]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

Tags: ofnonodetruedevicetheanothiskeras

热门问题