Problems compiling ofxDarknet

Hi all,

I am trying to make work ofxDarknet in ubuntu 16.04 and of_v20170714_linux64gcc5_release and i have installed Cuda 8 sdk. I check cuda with “nvcc --version” and all seems good installed. But all addons examples are failing when doing compilation with an error like this:
(full path)/addons/ofxDarknet/libs/darknet/include/cuda.h:15:26: fatal error: cuda_runtime.h: No such file or directory

Any ideas how i could fix or what i am doing wrong.

Looks like include path is only set for OSX and windows.

@MRZL ?

Here more notes. I am also trying in OSX (10.11.6) that was also complaint about “cuda_runtime.h”. I add cura path to addon_config.mk :

#ADDON_INCLUDES += /usr/local/cuda/include
ADDON_INCLUDES += /Developer/NVIDIA/CUDA-8.0/include/

Now the error is different, and now it is about libs:

dyld: Library not loaded: @rpath/libcurand.8.0.dylib
Referenced from: /Users/mcanet/Documents/of_v0.9.8_osx_release/addons/ofxDarknet/libs/darknet/lib/osx/libdarknetOSX.dylib
Reason: image not found

.dylib should be copied into inside of your .app in OSX.
Check how oF copy libfmodx.dylib.

And /Developer directory is unfamiliar for me. I don’t have it at my OSX’s top directory.

In ubuntu after modify addon_config.mk :

> #ADDON_INCLUDES += /usr/local/cuda/include
> ADDON_INCLUDES += /usr/local/cuda-8.0/include/	
> # I comment the following like after complain about it
> #ADDON_LDFLAGS = -rpath ../../../../addons/ofxDarknet/libs/darknet/lib/osx

Still not compile and this is the error output:

> ofxDarknet.cpp:(.text+0xae): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0xcd): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0x13d): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0x164): undefined reference to `max_index'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `void std::__adjust_heap<__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, long, unsigned long, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}> >(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, long, __gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long, __gnu_cxx::__ops::_Iter_comp_iter<ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)::{lambda(int, int)#1}>)':
> ofxDarknet.cpp:(.text+0x247): undefined reference to `max_index'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o:ofxDarknet.cpp:(.text+0x270): more undefined references to `max_index' follow
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::get_network_output_layer_gpu(int)':
> ofxDarknet.cpp:(.text+0x9a0): undefined reference to `cuda_pull_array'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::nightmare(ofPixels_<unsigned char>&, int, int, int, int, int, int, float, float)':
> ofxDarknet.cpp:(.text+0xa54): undefined reference to `make_image'
> ofxDarknet.cpp:(.text+0xbfa): undefined reference to `optimize_picture'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::rnn(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, float)':
> ofxDarknet.cpp:(.text+0xe6e): undefined reference to `get_network_input_size'
> ofxDarknet.cpp:(.text+0xf6f): undefined reference to `network_predict'
> ofxDarknet.cpp:(.text+0x106f): undefined reference to `network_predict'
> ofxDarknet.cpp:(.text+0x13a0): undefined reference to `sample_array'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::train_rnn(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
> ofxDarknet.cpp:(.text+0x15e1): undefined reference to `basecfg'
> ofxDarknet.cpp:(.text+0x160f): undefined reference to `parse_network_cfg'
> ofxDarknet.cpp:(.text+0x1635): undefined reference to `get_network_input_size'
> ofxDarknet.cpp:(.text+0x16d1): undefined reference to `rand_size_t'
> ofxDarknet.cpp:(.text+0x1732): undefined reference to `get_current_batch'
> ofxDarknet.cpp:(.text+0x176d): undefined reference to `get_rnn_data'
> ofxDarknet.cpp:(.text+0x179a): undefined reference to `train_network_datum'
> ofxDarknet.cpp:(.text+0x183e): undefined reference to `get_current_batch'
> ofxDarknet.cpp:(.text+0x185e): undefined reference to `sec'
> ofxDarknet.cpp:(.text+0x1885): undefined reference to `get_current_rate'
> ofxDarknet.cpp:(.text+0x192f): undefined reference to `rand_size_t'
> ofxDarknet.cpp:(.text+0x196d): undefined reference to `reset_rnn_state'
> ofxDarknet.cpp:(.text+0x1a0b): undefined reference to `save_weights'
> ofxDarknet.cpp:(.text+0x1a70): undefined reference to `save_weights'
> ofxDarknet.cpp:(.text+0x1ae5): undefined reference to `save_weights'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::convert(ofPixels_<unsigned char>&)':
> ofxDarknet.cpp:(.text+0x1b93): undefined reference to `make_image'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::classify(ofPixels_<unsigned char>&, int)':
> ofxDarknet.cpp:(.text+0x1e6a): undefined reference to `make_image'
> ofxDarknet.cpp:(.text+0x1f5b): undefined reference to `network_predict'
> ofxDarknet.cpp:(.text+0x1f81): undefined reference to `top_k'
> ofxDarknet.cpp:(.text+0x21c8): undefined reference to `free_image'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::getFeatureMaps(int)':
> ofxDarknet.cpp:(.text+0x293c): undefined reference to `cuda_pull_array'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
> ofxDarknet.cpp:(.text+0x2cb8): undefined reference to `parse_network_cfg'
> ofxDarknet.cpp:(.text+0x2cd7): undefined reference to `load_weights'
> ofxDarknet.cpp:(.text+0x2ce4): undefined reference to `set_batch_network'
> ofxDarknet.cpp:(.text+0x39ce): undefined reference to `get_labels'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/obj/linux64/Release/ofxDarknet/src/ofxDarknet.o: In function `ofxDarknet::yolo(ofPixels_<unsigned char>&, float, float)':
> ofxDarknet.cpp:(.text+0x3d5c): undefined reference to `make_image'
> ofxDarknet.cpp:(.text+0x3ede): undefined reference to `network_predict'
> ofxDarknet.cpp:(.text+0x3f27): undefined reference to `get_region_boxes'
> ofxDarknet.cpp:(.text+0x3f63): undefined reference to `do_nms_sort'
> ofxDarknet.cpp:(.text+0x3f7e): undefined reference to `free_image'
> ofxDarknet.cpp:(.text+0x4021): undefined reference to `cuda_pull_array'
> ofxDarknet.cpp:(.text+0x4343): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0x4366): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0x4450): undefined reference to `max_index'
> ofxDarknet.cpp:(.text+0x44a4): undefined reference to `get_color'
> ofxDarknet.cpp:(.text+0x44bf): undefined reference to `get_color'
> ofxDarknet.cpp:(.text+0x44d7): undefined reference to `get_color'
> ofxDarknet.cpp:(.text+0x4cd0): undefined reference to `free_ptrs'
> collect2: error: ld returned 1 exit status
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:403: recipe for target 'bin/example-deepdream' failed
> make[1]: *** [bin/example-deepdream] Error 1
> make[1]: Leaving directory '/home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/example-deepdream'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:124: recipe for target 'Release' failed

Hey @mar.canet,

I like the effort of getting it to work on Linux. I never really put time on it myself, rather struggled on windows. But since the original darknet compiles on ubuntu without any troubles, we can find a way.

You’re having linker errors because the addon does not contain the pre-compiled static libs for linux (only osx&windows). This is the key. I tried a little bit but couldnt get anywhere satisfying when trying to configure make to spit out a library instead of an executable.
I’m not sure how much time I have in the close future for this, but I am very happy to assist and test.

marcel :slight_smile:

Hola Mar,
If you check the linux branch it works, and use cuda 9.


Cheers

I had try now with linux branch done by @genekogan and setup addon_config.mk. I first used with cuda 8 that i had instaled and got this error compiling:

>  /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `forward_network_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `train_networks'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `network_predict_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `sync_nets'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `train_network_datum_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `backward_network_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `get_network_output_gpu'
> collect2: error: ld returned 1 exit status
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:403: recipe for target 'bin/example-deepdream' failed
> make[1]: *** [bin/example-deepdream] Error 1
> make[1]: Leaving directory '/home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/example-deepdream'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:124: recipe for target 'Release' failed
> make: *** [Release] Error 2

The I try like @charli_e said the cuda 9 and got different error output:

> /usr/bin/ld: warning: libcublas.so.8.0, needed by /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so, not found (try using -rpath or -rpath-link)
> /usr/bin/ld: warning: libcurand.so.8.0, needed by /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so, not found (try using -rpath or -rpath-link)
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `forward_network_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `train_networks'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `network_predict_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `sync_nets'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `cublasCreate_v2'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `train_network_datum_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `backward_network_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `curandGenerateUniform'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `get_network_output_gpu'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `curandCreateGenerator'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `curandSetPseudoRandomGeneratorSeed'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/libs/darknet/lib/linux64/libdarknetLinux.so: undefined reference to `cublasSgemm_v2'
> collect2: error: ld returned 1 exit status
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:403: recipe for target 'bin/example-deepdream' failed
> make[1]: *** [bin/example-deepdream] Error 1
> make[1]: Leaving directory '/home/titan2/Downloads/of_v20170714_linux64gcc5_release/addons/ofxDarknet/example-deepdream'
> /home/titan2/Downloads/of_v20170714_linux64gcc5_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:124: recipe for target 'Release' failed
> make: *** [Release] Error 2

Any ideas? should i need to recompile darket to get new libdarknetLinux.so

hey @mar.canet.
yeah, i had linker errors trying to compile ofxDarknet for linux last time i tried, and i think the trace you’re getting is the same. unfortunately i haven’t had time (or need) to look into this the last few months, and meanwhile the darknet master branch has had a lot of updates (which are not especially well-documented). @MRZL and i have talked a few times about revisiting this and getting ofxDarknet up-to-date (of course help would be appreciated). in the meantime, the Mac and Windows versions should be working fine right now.

did you managed to fix this ?or any clue how ?