简体   繁体   English

gpu时出现Keras(theano)错误

[英]Keras(theano) error while gpu

Already long time I try to understand with a problem. 很长时间以来,我一直试图理解一个问题。 Please help me. 请帮我。

I'm trying to run the 'Keras' example from the standard example git lib ( there ). 我正在尝试从标准示例git lib( there )运行'Keras'示例。

If I use CPU, then everything will works fine; 如果我使用CPU,则一切正常。 But, If I try to use GPU acceleration, it will crash WITHOUT catching any errors: 但是,如果我尝试使用GPU加速,它将崩溃而不会捕获任何错误:

# build the model: a single LSTM
print('Build model...')
print('   1')
model = Sequential()
print('   2')
model.add(LSTM(128, input_shape=(maxlen, len(chars))))
print('   3')
model.add(Dense(len(chars)))
print('   4')
model.add(Activation('softmax'))

print('   5')
optimizer = RMSprop(lr=0.01)

print('   Compilling')
model.compile(loss='categorical_crossentropy', optimizer=optimizer)

I put some print() for better understand the place of error. 我放了一些print()以便更好地了解错误的位置。 And what I get: 我得到的是:

runfile('C:/Users/kostya/Desktop/temp/python/test.py', wdir='C:/Users/kostya/Desktop/temp/python/')
Using Theano backend.
Using cuDNN version 5110 on context None
Preallocating 1638/2048 Mb (0.800000) on cuda
Mapped name None to device cuda: GeForce GTX 650 (0000:01:00.0)
WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly
DEVICE: cuda
corpus length: 206433
total chars: 79
nb sequences: 68798
Vectorization...
Build model...
   1
   2


Ядро остановилось, перезапуск *(It means: The Core has stopped, restarting)*

I will take Similar error, if I run it througth standatr python console. 如果我通过standatr python控制台运行它,我将遇到类似错误。 (python.exe emergency stops) (python.exe紧急停止)

I use: Win 10-64, Python 3.6.1, Anaconda with activated separate enviroment, CUDA 8.0, cuRNN 5.1, mkl 2017.0.3, numpy 1.13.0, theano 0.9.0, conda-forge.keras 2.0.2, m2w64-openblas 0.2.19, conda-forge.pygpu 0.6.8, VC 14.0 etc. 我使用:Win 10-64,Python 3.6.1,具有激活的单独环境的Anaconda,CUDA 8.0,cuRNN 5.1,mkl 2017.0.3,numpy 1.13.0,theano 0.9.0,conda-forge.keras 2.0.2,m2w64 -openblas 0.2.19,conda-forge.pygpu 0.6.8,VC 14.0等

That's my .theanorc.txt configurational file. 那是我的.theanorc.txt配置文件。 (I'm sure this can catch him. If I put the device = cpu - it works fine (but slowly)) (我确定这可以抓住他。 如果我将device = cpu放上,它可以正常工作 (但是很慢))

[global]
floatX = float32
device = cuda
optimizer_including = cudnn

[nvcc]
flags=-LC:\Users\kostya\Anaconda3\envs\keras\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

[cuda]
root = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

[dnn]
library_path = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
include_path = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include

[gpuarray]
preallocate = 0.8

You trying to use gpuarray backend option ( preallocate ) with CUDA backend. 您尝试将gpuarray后端选项( preallocate )与CUDA后端一起使用。 From Theano doc : 从Theano doc

This value allocates GPU memory ONLY when using (GpuArray Backend). 该值仅在使用(GpuArray Backend)时分配GPU内存。 For the old backend, please see config.lib.cnmem 有关旧的后端,请参阅config.lib.cnmem

Try replace in your Theano config 尝试在您的Theano配置中替换

[gpuarray]
preallocate = 0.8

with

[lib]
cnmem = 0.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM