Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for glibc 2.23 #4369

Closed
wants to merge 1 commit into from
Closed

Fix for glibc 2.23 #4369

wants to merge 1 commit into from

Conversation

ginggs
Copy link

@ginggs ginggs commented Apr 13, 2016

Avoid "error: 'memcpy' was not declared in the scope" with glibc 2.23.

Found in Ubuntu 16.04 with cuda 7.5.18, gcc 5.3.1 and glibc 2.23.

Avoid "error: 'memcpy' was not declared in the scope" with glibc 2.23.

Found in Ubuntu 16.04 with cuda 7.5.18, gcc 5.3.1 and glibc 2.23.
@@ -141,6 +141,9 @@ def compile_args():
flags.append('-arch=sm_' + str(p['major']) +
str(p['minor']))

# Needed for glibc 2.23
flags.append('-D_FORCE_INLINES')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this flag defined? I don't like to use flags I don't know about. Why not fix this by adding include?

Also, I only find memcpy in the CPU code. Do you have the problem with your own op? If not, which op is causing this problem?

@ginggs
Copy link
Author

ginggs commented Apr 13, 2016

@nouiz

Where is this flag defined?

_FORCE_INLINES is referenced several times in the glibc headers, in bits/string and bits/string2.h.

Why not fix this by adding include?

That could work too, I have no idea where to add the include though.

Also, I only find memcpy in the CPU code. Do you have the problem with your own op? If not, which op is causing this problem?

I was seeing the problem when running the sample from the 'Testing Theano with GPU' section in doc/tutorial/using_gpu.txt.

@nouiz
Copy link
Member

nouiz commented Apr 13, 2016

Can you give the full error message?

On Wed, Apr 13, 2016 at 12:03 PM, Graham Inggs [email protected]
wrote:

@nouiz https://github.com/nouiz

Where is this flag defined?

_FORCE_INLINES is referenced several times in the glibc headers, in
bits/string and bits/string2.h.

Why not fix this by adding include?

That could work too, I have no idea where to add the include though.

Also, I only find memcpy in the CPU code. Do you have the problem with
your own op? If not, which op is causing this problem?

I was seeing the problem when running the sample from the 'Testing Theano
with GPU' section in doc/tutorial/using_gpu.txt.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4369 (comment)

@ginggs
Copy link
Author

ginggs commented Apr 13, 2016

I run:
$ THEANO_FLAGS=floatX=float32,device=gpu python gpu_test.py
Then, omitting what I assume is generated code, I get:

mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3001): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3004): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3006): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3009): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3011): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3014): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3017): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3020): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3022): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3025): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3027): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3030): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3032): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3035): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3038): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3041): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3043): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3046): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3048): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3051): warning: conversion from a string literal to "char *" is deprecated
mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3001): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3004): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3006): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3009): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3011): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3014): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3017): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3020): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3022): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3025): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3027): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3030): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3032): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3035): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3038): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3041): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3043): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3046): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3048): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3051): warning: conversion from a string literal to "char *" is deprecated
/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;
                                          ^
mod.cu: In function ‘PyObject* CudaNdarray_Reshape(CudaNdarray*, PyObject*)’:
mod.cu:955:122: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
         PyErr_Format(PyExc_ValueError, "size must remain unchanged, changed from %lld to %lld", CudaNdarray_SIZE(self), rval_size);
                                                                                                                          ^
mod.cu:955:122: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=]

['nvcc', '-shared', '-O3', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden', '-Xlinker', '-rpath,/home/ginggs/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray', '-I/usr/lib/python2.7/dist-packages/theano/sandbox/cuda', '-I/usr/lib/python2.7/dist-packages/numpy/core/include', '-I/usr/include/python2.7', '-I/usr/lib/python2.7/dist-packages/theano/gof', '-o', '/home/ginggs/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray/cuda_ndarray.so', 'mod.cu', '-L/usr/lib', '-lcublas', '-lpython2.7', '-lcudart']
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 1, 'for cmd', 'nvcc -shared -O3 -m64 -Xcompiler -DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/ginggs/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray -I/usr/lib/python2.7/dist-packages/theano/sandbox/cuda -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/theano/gof -o /home/ginggs/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray/cuda_ndarray.so mod.cu -L/usr/lib -lcublas -lpython2.7 -lcudart')
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available  (error: cuda unavailable)
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 26.665643 seconds
Result is [ 1.23178029  1.61879337  1.52278066 ...,  2.20771813  2.29967761
  1.62323284]
Used the cpu

@abergeron
Copy link
Member

<string.h> is the header that is supposed to define memcpy. If it requires arcane defines to work properly, that is a bug in your install and you should fix it.

If you just want a quick solution for yourself, you can always add the define you want in gcc.cxxflags in your Theano config.

@nouiz
Copy link
Member

nouiz commented Apr 13, 2016

For a quick fix, put it in the nvcc.flags Theano flag as this is needed
only for nvcc.
I also think that there is a problem with your installation stack. Could it
be that you use a version of nvcc that don't support your current gcc/g++
version?

/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;

Here we see that the error is in your OS, not in Theano.

On Wed, Apr 13, 2016 at 2:37 PM, abergeron [email protected] wrote:

<string.h> is the header that is supposed to define memcpy. If it
requires arcane defines to work properly, that is a bug in your install and
you should fix it.

If you just want a quick solution for yourself, you can always add the
define you want in gcc.cxxflags in your Theano config.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4369 (comment)

@ginggs
Copy link
Author

ginggs commented Apr 14, 2016

@nouiz

For a quick fix, put it in the nvcc.flags Theano flag as this is needed only for nvcc.

Thanks! Confirming that this works for me:

$ THEANO_FLAGS=floatX=float32,device=gpu,nvcc.flags=-D_FORCE_INLINES python gpu_test.py

I also think that there is a problem with your installation stack. Could it be that you use a version of nvcc that don't support your current gcc/g++ version?

It could be that gcc 5.3.1is not officially supported by Nvidia, but I have come across numerous compilation problems similar to 'memcpy' was not declared in the scope (e.g. with isnan and isinf) since the upgrade to glibc 2.2.3.

@abergeron
Copy link
Member

Indeed cuda 7.5 supports gcc 4.7, 4.8 and 4.9.

Also if you are having multiple problems of this nature, that more strongly suggests that either glibc 2.2.3 is broken or your package of it is.

I am now closing this since the problem is not in Theano.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants