【问题标题】:Keras(theano) error while gpuGPU时Keras(theano)错误
【发布时间】:2017-07-07 11:34:16
【问题描述】:

我已经很长时间试图理解一个问题。请帮帮我。

我正在尝试从标准示例 git lib (there) 运行“Keras”示例。

如果我使用 CPU,那么一切都会正常;但是,如果我尝试使用 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)

我放了一些print() 以便更好地了解错误的地方。 我得到了什么:

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)*

如果我通过standatr python 控制台运行它,我会遇到类似的错误。 (python.exe 紧急停止)

我使用: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等

这是我的.theanorc.txt 配置文件。 (我相信这可以抓住他。如果我输入 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

【问题讨论】:

    标签: python deep-learning gpu keras theano


    【解决方案1】:

    您尝试将 gpuarray 后端选项 (preallocate) 与 CUDA 后端一起使用。来自 Theano doc:

    此值仅在使用 (GpuArray Backend) 时分配 GPU 内存。旧后端请查看 config.lib.cnmem

    尝试在您的 Theano 配置中替换

    [gpuarray]
    preallocate = 0.8
    

    [lib]
    cnmem = 0.8
    

    【讨论】:

    • 谢谢,但它不起作用。在这种情况下,它甚至没有分配 0.8 的内存。我使用支持 GpuArray 后端的 CUDA 8.0 和 Theano 0.9.0。
    猜你喜欢
    • 2017-05-13
    • 2016-07-13
    • 2016-03-11
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    相关资源
    最近更新 更多