milakov / nnForge

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

Error compiling examples - image_classifier_demo and gtsrb #15

Closed anshumang closed 9 years ago

anshumang commented 9 years ago

I started by building the sources under nnforge, nnforge/plain and nnforge/cuda. In my Settings.mk, I have - ENABLE_CUDA_BACKEND=yes CPP11COMPILER=no NETCDF_INSTALLED=no MATIO_INSTALLED=no

When I run "make" under examples/image_classifier_demo, I get the following errors (symbols not found in the generated libraries)- g++ -o ../../bin/image_classifier_demo image_classifier_demo.o image_classifier_demo_toolset.o -lnnforge_cuda -lnnforge_plain -lnnforge -L../../lib -L/usr/lib -lboost_thread -lboost_regex -lboost_chrono -lboost_filesystem -lboost_program_options -lboost_random -lboost_system -lboost_date_time -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcusparse -lcublas -lcudart -L/usr/lib/x86_64-linux-gnu//lib -lopencv_highgui -lopencv_imgproc -lopencv_core -fopenmp image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::image_classifier_demo_toolset(std::shared_ptr<nnforge::factory_generator>)': image_classifier_demo_toolset.cpp:(.text+0x6dc): undefined reference tonnforge::neural_network_toolset::neural_network_toolset(std::shared_ptrnnforge::factory_generator)' image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::run_classifier_loop()': image_classifier_demo_toolset.cpp:(.text+0x19e7): undefined reference tonnforge::network_tester::set_data(std::shared_ptrnnforge::network_data)' image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::init_input_config()': image_classifier_demo_toolset.cpp:(.text+0x255d): undefined reference tonnforge::network_schema::operator std::vector<std::shared_ptr, std::allocator<std::shared_ptr > > const&() const' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0x98): undefined reference to nnforge::neural_network_toolset::get_validators_for_training(std::shared_ptr<nnforge::network_schema>)' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0xb8): undefined reference tonnforge::neural_network_toolset::run_test_with_unsupervised_data(std::vectorstd::shared_ptr<nnforge::output_neuron_value_set, std::allocatorstd::shared_ptr >&)' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0x118): undefined reference to `nnforge::neural_network_toolset::get_samples_for_snapshot(std::shared_ptrnnforge::network_data, std::shared_ptrnnforge::unsupervised_data_reader, unsigned int)' collect2: error: ld returned 1 exit status make: *\ [../../bin/image_classifier_demo] Error 1

Similar errors for examples/gtsrb- g++ -o ../../bin/gtsrb gtsrb.o gtsrb_toolset.o -lnnforge_cuda -lnnforge_plain -lnnforge -L../../lib -L/usr/lib -lboost_thread -lboost_regex -lboost_chrono -lboost_filesystem -lboost_program_options -lboost_random -lboost_system -lboost_date_time -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcusparse -lcublas -lcudart -L/usr/lib/x86_64-linux-gnu//lib -lopencv_highgui -lopencv_imgproc -lopencv_core -fopenmp gtsrb_toolset.o: In function gtsrb_toolset::gtsrb_toolset(std::shared_ptr<nnforge::factory_generator>)': gtsrb_toolset.cpp:(.text+0x13d3): undefined reference tonnforge::neural_network_toolset::neural_network_toolset(std::shared_ptrnnforge::factory_generator)' gtsrb_toolset.o: In function gtsrb_toolset::get_schema() const': gtsrb_toolset.cpp:(.text+0x1623): undefined reference tonnforge::network_schema::add_layer(std::shared_ptr)' gtsrb_toolset.cpp:(.text+0x177c): undefined reference to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' gtsrb_toolset.cpp:(.text+0x17e3): undefined reference tonnforge::network_schema::add_layer(std::shared_ptr)' gtsrb_toolset.cpp:(.text+0x1826): undefined reference to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' gtsrb_toolset.cpp:(.text+0x190b): undefined reference tonnforge::network_schema::add_layer(std::shared_ptr)' gtsrb_toolset.o:gtsrb_toolset.cpp:(.text+0x1a52): more undefined references to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' follow gtsrb_toolset.o: In functiongtsrb_toolset::prepare_training_data()': gtsrb_toolset.cpp:(.text+0x301f): undefined reference to nnforge::supervised_data_stream_writer::supervised_data_stream_writer(std::shared_ptr<std::ostream>, nnforge::layer_configuration_specific const&, nnforge::layer_configuration_specific const&, nnforge::neuron_data_type::input_type)' gtsrb_toolset.cpp:(.text+0x3c5e): undefined reference tonnforge::supervised_data_stream_writer::supervised_data_stream_writer(std::shared_ptrstd::ostream, nnforge::layer_configuration_specific const&, nnforge::layer_configuration_specific const&, nnforge::neuron_data_type::input_type)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0x98): undefined reference to nnforge::neural_network_toolset::get_validators_for_training(std::shared_ptr<nnforge::network_schema>)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0xb8): undefined reference tonnforge::neural_network_toolset::run_test_with_unsupervised_data(std::vectorstd::shared_ptr<nnforge::output_neuron_value_set, std::allocatorstd::shared_ptr >&)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0x118): undefined reference to `nnforge::neural_network_toolset::get_samples_for_snapshot(std::shared_ptrnnforge::network_data, std::shared_ptrnnforge::unsupervised_data_reader, unsigned int)' collect2: error: ld returned 1 exit status make: *\ [../../bin/gtsrb] Error 1

milakov commented 9 years ago

Please follow https://github.com/milakov/nnForge/blob/master/README.md You need to run ./make_all.sh in the root project directory to build nnforge, CPU and GPU backends first, then it build examples. Hope it helps.

anshumang commented 9 years ago

Thanks for your reply Maxim. Yes I did that too. Ran sh make_all.sh from the root directory. The build fails when the script runs make on examples/ Let me send you the log.

anshumang commented 9 years ago

~/nnForge$ sh make_all.sh make: Nothing to be done for all'. make: Nothing to be done forall'. make: Nothing to be done for all'. g++ -o ../../bin/gtsrb gtsrb.o gtsrb_toolset.o -lnnforge_cuda -lnnforge_plain -lnnforge -L../../lib -L/usr/lib -lboost_thread -lboost_regex -lboost_chrono -lboost_filesystem -lboost_program_options -lboost_random -lboost_system -lboost_date_time -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcusparse -lcublas -lcudart -L/usr/lib/x86_64-linux-gnu//lib -lopencv_highgui -lopencv_imgproc -lopencv_core -fopenmp gtsrb_toolset.o: In functiongtsrb_toolset::gtsrb_toolset(std::shared_ptrnnforge::factory_generator)': gtsrb_toolset.cpp:(.text+0x13d3): undefined reference to nnforge::neural_network_toolset::neural_network_toolset(std::shared_ptr<nnforge::factory_generator>)' gtsrb_toolset.o: In functiongtsrb_toolset::get_schema() const': gtsrb_toolset.cpp:(.text+0x1623): undefined reference to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' gtsrb_toolset.cpp:(.text+0x177c): undefined reference tonnforge::network_schema::add_layer(std::shared_ptr)' gtsrb_toolset.cpp:(.text+0x17e3): undefined reference to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' gtsrb_toolset.cpp:(.text+0x1826): undefined reference tonnforge::network_schema::add_layer(std::shared_ptr)' gtsrb_toolset.cpp:(.text+0x190b): undefined reference to nnforge::network_schema::add_layer(std::shared_ptr<nnforge::layer const>)' gtsrb_toolset.o:gtsrb_toolset.cpp:(.text+0x1a52): more undefined references tonnforge::network_schema::add_layer(std::shared_ptr)' follow gtsrb_toolset.o: In function gtsrb_toolset::prepare_training_data()': gtsrb_toolset.cpp:(.text+0x301f): undefined reference tonnforge::supervised_data_stream_writer::supervised_data_stream_writer(std::shared_ptrstd::ostream, nnforge::layer_configuration_specific const&, nnforge::layer_configuration_specific const&, nnforge::neuron_data_type::input_type)' gtsrb_toolset.cpp:(.text+0x3c5e): undefined reference to nnforge::supervised_data_stream_writer::supervised_data_stream_writer(std::shared_ptr<std::ostream>, nnforge::layer_configuration_specific const&, nnforge::layer_configuration_specific const&, nnforge::neuron_data_type::input_type)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0x98): undefined reference tonnforge::neural_network_toolset::get_validators_for_training(std::shared_ptrnnforge::network_schema)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0xb8): undefined reference to nnforge::neural_network_toolset::run_test_with_unsupervised_data(std::vector<std::shared_ptr<nnforge::output_neuron_value_set>, std::allocator<std::shared_ptr<nnforge::output_neuron_value_set> > >&)' gtsrb_toolset.o:(.rodata._ZTV13gtsrb_toolset[_ZTV13gtsrb_toolset]+0x118): undefined reference tonnforge::neural_network_toolset::get_samples_for_snapshot(std::shared_ptrnnforge::network_data, std::shared_ptrnnforge::unsupervised_data_reader, unsigned int)' collect2: error: ld returned 1 exit status make: * [../../bin/gtsrb] Error 1 g++ -o ../../bin/image_classifier_demo image_classifier_demo.o image_classifier_demo_toolset.o -lnnforge_cuda -lnnforge_plain -lnnforge -L../../lib -L/usr/lib -lboost_thread -lboost_regex -lboost_chrono -lboost_filesystem -lboost_program_options -lboost_random -lboost_system -lboost_date_time -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcusparse -lcublas -lcudart -L/usr/lib/x86_64-linux-gnu//lib -lopencv_highgui -lopencv_imgproc -lopencv_core -fopenmp image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::image_classifier_demo_toolset(std::shared_ptr<nnforge::factory_generator>)': image_classifier_demo_toolset.cpp:(.text+0x6dc): undefined reference tonnforge::neural_network_toolset::neural_network_toolset(std::shared_ptrnnforge::factory_generator)' image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::run_classifier_loop()': image_classifier_demo_toolset.cpp:(.text+0x19e7): undefined reference tonnforge::network_tester::set_data(std::shared_ptrnnforge::network_data)' image_classifier_demo_toolset.o: In function image_classifier_demo_toolset::init_input_config()': image_classifier_demo_toolset.cpp:(.text+0x255d): undefined reference tonnforge::network_schema::operator std::vector<std::shared_ptr, std::allocator<std::shared_ptr > > const&() const' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0x98): undefined reference to nnforge::neural_network_toolset::get_validators_for_training(std::shared_ptr<nnforge::network_schema>)' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0xb8): undefined reference tonnforge::neural_network_toolset::run_test_with_unsupervised_data(std::vectorstd::shared_ptr<nnforge::output_neuron_value_set, std::allocatorstd::shared_ptr >&)' image_classifier_demo_toolset.o:(.rodata._ZTV29image_classifier_demo_toolset[_ZTV29image_classifier_demo_toolset]+0x118): undefined reference to `nnforge::neural_network_toolset::get_samples_for_snapshot(std::shared_ptrnnforge::network_data, std::shared_ptrnnforge::unsupervised_data_reader, unsigned int)' collect2: error: ld returned 1 exit status make: * [../../bin/image_classifier_demo] Error 1

milakov commented 9 years ago

Please check nnForge/lib directory: do you have libnnforge.a, libnnforge_plain.a and libnnforge_cuda.a there? What do you have if you chdir to nnForge/nnforge and run make there?

anshumang commented 9 years ago

Yes they are there. pwd /home/agoswami/nnForge agoswami@ifrit:~/nnForge$ ls lib/ libnnforge.a libnnforge_cuda.a libnnforge_plain.a

On running make under nnForge/nnforge, I get the following - cd nnforge/ agoswami@ifrit:~/nnForge/nnforge$ make make: Nothing to be done for `all'.

My gcc is 4.8.2 on Ubuntu 14.04

milakov commented 9 years ago

I have exactly the same dev configurattion, Ubuntu 14.04, gcc 4.8.2. I suggest you to run "./make_all.sh clean" and then build everything "./make_all.sh"

If it doesn't help could you please copy content of Settings.mk here? It looks like you switched c++11 mode on, maybe there are other changes too.

anshumang commented 9 years ago

Here's my Settings.mk - BUILD_MODE=release ENABLE_CUDA_BACKEND=yes ENABLE_CUDA_PROFILING=no CPP11COMPILER=no BOOST_PATH=/usr OPENCV_PATH=/usr/lib/x86_64-linux-gnu/ NETCDF_INSTALLED=no NETCDF_PATH= 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

BOOST_LIBS=-lboost_thread -lboost_regex -lboost_chrono -lboost_filesystem -lboost_program_options -lboost_random -lboost_system -lboost_date_time OPENCV_LIBS=-lopencv_highgui -lopencv_imgproc -lopencv_core NETCDF_LIBS=-lnetcdf MATIO_LIBS=-lmatio

CPP_FLAGS_CPP11=-std=c++11 CPP_HW_ARCHITECTURE=-march=native # set this to -march=corei7 if you see AVX related errors when CPP11COMPILER=yes CPP_FLAGS_COMMON=-ffast-math $(CPP_HW_ARCHITECTURE) -mfpmath=sse -msse2 # -mavx CPP_FLAGS_DEBUG_MODE=-g CPP_FLAGS_RELEASE_MODE=-O3

CPP_FLAGS_OPENMP=-fopenmp LD_FLAGS_OPENMP=-fopenmp

CUDA_FLAGS_COMMON=-use_fast_math -DBOOST_NOINLINE='attribute ((noinline))' CUDA_FLAGS_ARCH_FERMI=-gencode=arch=compute_20,code=sm_20 CUDA_FLAGS_ARCH_KEPLER=-gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=\"sm_35,compute_35\" CUDA_FLAGS_DEBUG_MODE=-g -lineinfo CUDA_FLAGS_RELEASE_MODE=-O3

Rebuilding after clean....

anshumang commented 9 years ago

Builds correctly after clean....I am sorry but probably there was some issue because my build last time was interrupted by the machine going into sleep mode, after which I reran the script...thanks for your help !

milakov commented 9 years ago

Sure, no problem. Good to know it works!