milakov / nnForge

Convolutional neural networks C++ framework with CPU and GPU (CUDA) backends
http://nnforge.org
177 stars 44 forks source link

cuda fails to build when c++11 #9

Closed soumith closed 10 years ago

soumith commented 10 years ago

Hey,

I am trying to build nnForge on my machine: Ubuntu 14.04 64-bit with CUDA 6.0

I am running into two different issues: (1) When CPP11COMPILER=yes the CUDA modules fail to build with the error:

nvcc -c absolute_layer_hessian_cuda.cu -use_fast_math -DBOOST_NOINLINE='__attribute__ ((noinline))' -O3 -DENABLE_CUDA_PROFILING -Xcompiler="-I/usr/local/include -I/usr/local/cuda/include -I/usr/local/include -ffast-math -march=native -mfpmath=sse -msse2  -O3 -DENABLE_CUDA_PROFILING" -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=\"sm_35,compute_35\" -o absolute_layer_hessian_cuda.o
In file included from /usr/include/c++/4.8/random:35:0,
                 from ../nn_types.h:20,
                 from ../layer_data.h:20,
                 from ../layer.h:21,
                 from layer_hessian_cuda.h:19,
                 from absolute_layer_hessian_cuda.h:19,
                 from absolute_layer_hessian_cuda.cu:17:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \

(2) With CPP11COMPILER=no the core library itself fails to build with the error:

g++ -I/usr/local/include/boost/tr1/tr1 -I/usr/local/include -I/usr/local/include -ffast-math -march=native -mfpmath=sse -msse2  -O3 -DENABLE_CUDA_PROFILING   -c -o absolute_layer.o absolute_layer.cpp
In file included from /usr/include/c++/4.8/random:35:0,
                 from nn_types.h:20,
                 from layer_data.h:20,
                 from layer.h:21,
                 from absolute_layer.h:19,
                 from absolute_layer.cpp:17:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from layer_data.h:20:0,
                 from layer.h:21,
                 from absolute_layer.h:19,
                 from absolute_layer.cpp:17:
nn_types.h:41:25: error: ‘tr1’ in namespace ‘std’ does not name a type
 #define nnforge_mt19937 std::tr1::mt19937
                         ^
rnd.h:23:10: note: in expansion of macro ‘nnforge_mt19937’
  typedef nnforge_mt19937 random_generator;
          ^
soumith commented 10 years ago

This is my Settings.mk

--- a/Settings.mk
+++ b/Settings.mk
@@ -1,18 +1,18 @@
 BUILD_MODE=release
 ENABLE_CUDA_BACKEND=yes
-ENABLE_CUDA_PROFILING=no
-CPP11COMPILER=no
+ENABLE_CUDA_PROFILING=yes
+CPP11COMPILER=yes
 BOOST_PATH=/usr/local
 OPENCV_PATH=/usr/local
-NETCDF_INSTALLED=yes
+NETCDF_INSTALLED=no
 NETCDF_PATH=
-MATIO_INSTALLED=yes
+MATIO_INSTALLED=no
 MATIO_PATH=
 CUDA_PATH=/usr/local/cuda
 NVCC=nvcc
 NNFORGE_PATH=../..
-NNFORGE_INPUT_DATA_PATH=/home/max/nnforge/input_data
-NNFORGE_WORKING_DATA_PATH=/home/max/nnforge/working_data
+NNFORGE_INPUT_DATA_PATH=./nnforge/input_data
+NNFORGE_WORKING_DATA_PATH=./nnforge/working_data
soumith commented 10 years ago

If you've seen these issues before, or if there's a standard script to install nnForge with CUDA support for Ubuntu, please let me know.

Thanks!

soumith commented 10 years ago

My main goal is to benchmark all the ConvNet libraries with reproducible instructions/scripts. Located here: https://github.com/soumith/convnet-benchmarks

milakov commented 10 years ago

Hi Soumith,

CPP11COMPILER=no # CUDA doesn't support C++11 yet BOOST_PATH=/usr # If you install Boost through deb packages they are here

This is not the first time developers encounter this problem. It looks like I should set BOOST_PATH=/usr in Settings.mk

soumith commented 10 years ago

Thank you!

soumith commented 10 years ago

Also, the boost libraries are no longer post-fixed by "-mt" in the latest versions, they are built multi-threaded by default, had to change that as well, fyi.

milakov commented 10 years ago

Yeah, thanks, good point.

milakov commented 10 years ago

This issue is fixed with CUDA 6.5: you can now build CUDA backend with -std=c++11

If you see AVX related errors when CPP11COMPILER=yes then set CPP_HW_ARCHITECTURE=-march=corei7 This workaround should work.