简体   繁体   English

Keras无法使用theano后端进行编译

[英]Keras failed to compile with theano backend

I get the following error when I try the compile the example in the keras documentation. 当我尝试编译keras文档中的示例时,我收到以下错误。

/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
   return (char *) memcpy (__dest, __src, __n) + __n;
                                          ^
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 1, 'for cmd', 'nvcc -shared -O3 -m64 -Xcompiler -DCUDA_NDARRAY_CUH=mc72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/chase/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray -I/usr/local/lib/python3.5/dist-packages/theano/sandbox/cuda -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.5m -I/usr/local/lib/python3.5/dist-packages/theano/gof -o /home/chase/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray/cuda_ndarray.so mod.cu -L/usr/lib -lcublas -lpython3.5m -lcudart')

I am on Ubuntu 16.04. 我在Ubuntu 16.04上。 I am using CUDA 7.5 which I installed from the default repositories. 我正在使用从默认存储库安装的CUDA 7.5。 I have used the CUDA to compile some of my own cuda programs as well as ArrayFire programs so I know CUDA is working. 我使用CUDA编译了一些我自己的cuda程序以及ArrayFire程序,所以我知道CUDA正在工作。

Here is what I tried to compile... 这是我试图编译的...

from keras.models import Sequential

model = Sequential()
from keras.layers.core import Dense, Activation

model.add(Dense(output_dim=64, input_dim=100))
model.add(Activation("relu"))
model.add(Dense(output_dim=10))
model.add(Activation("softmax"))

model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy'])

It appears there is an issue with GCC 5.3 and CUDA. 似乎GCC 5.3和CUDA存在问题。 I had to comment out the following changes in /usr/include/string.h and now it works. 我必须在/usr/include/string.h中注释掉以下更改,现在它可以正常工作。

https://fossies.org/diffs/glibc/2.22_vs_2.23/string/string.h-diff.html https://fossies.org/diffs/glibc/2.22_vs_2.23/string/string.h-diff.html

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

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