Closed stephanecharette closed 4 years ago
Thanks, @AlexeyAB, for looking into this. It certainly will simplify publishing 3rd party libraries and tools that build on libdarknet.so.
@stephanecharette
I fixed it: https://github.com/AlexeyAB/darknet/commit/ef979a1fd2d14f41c65aa4b15a5f1db390b7bb43
Did a git pull tonight and finally had a chance to try this out. Thanks, @AlexeyAB, the size of the structures are now exactly the same when building the various flavours.
3rd party libraries like DarkHelp that use libdarknet.so must
#include <darknet.h>
, and also reference thenetwork
andlayer
structures.The problem is those structures have some optional fields within
#ifdef GPU
and#ifdef CUDNN
blocks. So depending on whether support for GPU/CUDNN was toggled in darknet's makefile, this means the network and layer structures change size!In my case tonight, I tracked down a segfault that was caused by this issue. A 3rd party lib that didn't define either GPU nor CUDNN before including darknet.h. So the structures were the wrong size, leading to a segfault caused by
memcpy()
located withinnetwork_predict_gpu()
.What this means is all my .deb libraries that have code which #include darknet.h need to be published in 3 flavours:
Any chance we can always include those optional GPU and CUDNN fields in the structs defined in darknet.h even when building without full GPU/CUDNN support? It means the structs would be slightly larger on CPU-only, but then there wouldn't be this incompatibility.