build error using gcc 5

15,711 views
Skip to first unread message

Jacob

unread,
Apr 11, 2016, 11:54:58 PM4/11/16
to Caffe Users
I am using GCC 5.x to build caffe. I have used the work around in https://gist.github.com/wangruohui/679b05fcd1466bb0937f
I get the following error message below. I have added cudnn and python layer support from the default makefile. When I make cafe with debug I get no error message and I am able to train networks successfully.

...
NVCC src/caffe/layers/scale_layer.cu
NVCC src/caffe/layers/cudnn_sigmoid_layer.cu
NVCC src/caffe/layers/base_data_layer.cu
NVCC src/caffe/layers/split_layer.cu
NVCC src/caffe/layers/hdf5_output_layer.cu
NVCC src/caffe/layers/crop_layer.cu
NVCC src/caffe/layers/hdf5_data_layer.cu
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/cudnn_sigmoid_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/cudnn_sigmoid_layer.o] Error 1
make: *** Waiting for unfinished jobs....
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/scale_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/scale_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/base_data_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/base_data_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/split_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/split_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/hdf5_output_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/hdf5_output_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/crop_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/crop_layer.o] Error 1
/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;
                                          ^
Makefile:586: recipe for target '.build_release/cuda/src/caffe/layers/hdf5_data_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/hdf5_data_layer.o] Error 1

Jicheng Wang

unread,
Apr 16, 2016, 11:33:15 AM4/16/16
to Caffe Users
I have the same problems. But when I Add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORCE_INLINES") to the front of CMakeLists.txt, It works!!!

在 2016年4月12日星期二 UTC+8上午11:54:58,Jacob写道:

Haoyu Y

unread,
Apr 21, 2016, 1:03:27 PM4/21/16
to Caffe Users
hi Jacob,

I encountered the same problem in the latest ubuntu 16.04 with gcc version 5.3. Have you solved the problem?

Jicheng Wang

unread,
Apr 22, 2016, 8:58:56 AM4/22/16
to Caffe Users
Try to add this line  "set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORCE_INLINES")" to the front of CMakefile.txt and use the CMake to build caffe. It should solve this problem. I also use the Ubuntu 16.04 and gcc 5.3

在 2016年4月22日星期五 UTC+8上午1:03:27,Haoyu Y写道:

Jacob

unread,
Apr 23, 2016, 2:28:43 AM4/23/16
to Caffe Users
I initially thought Jicheng solution worked but it was a false alarm. I have yet to find a way around it.
A simple hack is to comment out all the debug print statement in the .cpp layers before the build and compile it with debug mode.

Luke Yeager

unread,
Apr 25, 2016, 7:17:21 PM4/25/16
to Caffe Users
Worked for me too, thanks!

Haoyu Y

unread,
Apr 26, 2016, 12:01:22 AM4/26/16
to Caffe Users
Thanks Jicheng, that works. I think currently we can only use cmake to compile caffe with gcc > 5.0.

Osman Tursun

unread,
Apr 27, 2016, 9:49:17 AM4/27/16
to Caffe Users
I also the Ubuntu 16.04 and gcc 5.3, but the solution did not work. Is there a any other solution ?

Kujtim Rahmani

unread,
May 9, 2016, 6:18:43 PM5/9/16
to Caffe Users
try this http://stackoverflow.com/questions/37083936/keras-failed-to-compile-with-theano-backend 
you have to cmment some lines of code in /usr/include/string.h

Werner Van Belle

unread,
May 27, 2016, 12:52:31 PM5/27/16
to Caffe Users
Hello,

The FORCE_INLINES idea was a good one. However, to get it to work without using cmake you have to modify the Makefile instead:

Add to the end of COMMON_FLAGS (Makefile line ~42): -D_FORCE_INLINES

With kind regards,

Werner,-

Shane nunya

unread,
Jun 25, 2016, 9:18:58 PM6/25/16
to Caffe Users
Thanks Werner, I only have a Makefile to deal with and your fix was what I needed.

For anyone else finding this on google
NVIDIA_CUDA-7.5_Samples/6_Advanced/shfl_scan/Makefile:149

CCFLAGS += -D_FORCE_INLINES


 

Fra Rossi

unread,
Jul 30, 2018, 6:36:19 PM7/30/18
to Caffe Users
It works for me too!
(Ubuntu 16 gcc 5.5)
Thanks
Reply all
Reply to author
Forward
0 new messages