1
votes

I have successfully built the "Release x64" version of AlexeyAB's C/C++ solution called darknet. I am using a PC with Windows 10 Professional, Visual Studio Community 2019, an NVIDIA GeForce RTX 2080 Ti GPU, CUDA 10.2, cuDNN 7.6.5, and OpenCV 4.1.2.

While I have successfully built the "Release x64" version of darknet, the Debug version fails to build due to three errors:

  1. MSB3721 associated with line 764 of CUDA 10.2.targets:
The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64" -x cu  -IC:\opencv_4.1.2\opencv\build\include -I..\..\include -I..\..\3rdparty\stb\include -I..\..\3rdparty\pthreads\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -I\include -I\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static  -g   -DCUDNN_HALF -DCUDNN -D_CRTDBG_MAP_ALLOC -D_MBCS -D_TIMESPEC_DEFINED -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_RAND_S -DGPU -DWIN32 -DDEBUG -D_CONSOLE -D_LIB -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Fdx64\Debug\vc142.pdb /FS /Zi /RTC1 /MDd " -o x64\Debug\network_kernels.cu.obj "C:\Users\Tom\Documents\AI\darknet\darknet\src\network_kernels.cu"" exited with code 1.
  1. An error associated with lines 149 and 150 of common_functions.h:
more than one instance of overloaded function "_malloc_dbg" has "C" linkage.
  1. An error associated with lines 149 and 150 of common_functions.h:
expected a type specifier.

Does anyone have any suggestions for resolving these three errors? It could be that these three errors are related. Someone suggested modifying the -ccbin option to reference a different compiler. If this seems likely, would you please offer concrete steps for changing this option? Are there other things I can do?

1
My intuition is that the first build error is due to the other two build errors. I suppressed all build errors by changing Project Configuration Properties -> C/C++ -> Code Generation -> Runtime Library from "Multi-threaded Debug DLL (/MDd)" to "Multi-threaded DLL (/MD)". Unfortunately, when I build in "Debug x64" mode with "Multi-threaded DLL (/MD)" code generation, OpenCV's Release libraries are used with a Debug build; I run into a memory-access error with cv::imread. Does anyone have any other suggestions relating to above errors 2 and 3?Tom Lever
Hi Tom. Any luck with this? We've run into the exact same issue.Zaphod
remove _CRTDBG_MAP_ALLOC from Properties->C/C++/Preprocessor->Preprocessor DefinitionsMERN

1 Answers

2
votes

I had this problem. I tracked it down to my debug version having a MACRO defined: _CRTDBG_MAP_ALLOC. MS doc states:

When the _CRTDBG_MAP_ALLOC flag is defined in the debug version of an application, the base version of the heap functions are directly mapped to their debug versions. The flag is used in Crtdbg.h to do the mapping. This flag is only available when the _DEBUG flag has been defined in the application.

So it appears that this causes a conflict due to different versions of malloc and free being declared. Remove the definition and you should be good. I don't need debug versions of these functions in my debug build and you probably don't either. By the way, the setting/flag/definition is at:

Properties->C/C++/Preprocessor->Preprocessor Definitions