Addressing Errors Associated with Building the "Debug x64" Version of darknet

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.1, 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.1.targets:
The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\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.23.28105\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.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -I\include -I\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\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? Is the first error due to NVCC.exe trying to use the wrong compiler cl.exe? If so, how would I redirect NVCC / Visual Studio to a different version of cl.exe?

Increase the verbosity of the build log to see what exactly triggers problem #1. The other two issues might be follow-on issues triggered by that first failure.

The nvcc command line switch -ccbin lets you point nvcc to a particular host compiler executable. For example, I have the Intel compiler installed on my Windows machine in addition to MSVC. Since both are in my PATH, I can just add

-ccbin icl.exe

to my nvcc command line to build host code with the Intel compiler instead of MSVC. Note: As far as I know, use of the Intel compiler on Windows is officially not supported by CUDA, but it seems to work well enough for my simple programs, modulo a few harmless warnings that I ignore.

njuffa,

Thank you very much for a prompt and helpful reply. I increased my verbosity to Detailed and then to Diagnostic; unfortunately, all I really saw in Diagnostic mode were many many mentions of the path to the nvcc executable and references to some compile property. Maybe I should take another look with a finer tooth comb?

Would you be willing to suggest some step-by-step instructions for repointing the nvcc executable permanently to a specific compiler (icl.exe or cl.exe, either as part of my system PATH variable)? Or, if it’s more appropriate, having Visual Studio 2019 Community build the “Debug x64” versión of darknet with a different compiler, or passing the path to its compiler or a different compiler to nvcc? Maybe my question is, "How do I change the Visual-Studio automatically generated command line call to nvcc?

Thanks so much,

Tom Lever

hi,Tom

I am currently having the same problem.
I am using a PC with Windows 10 Professional, Visual Studio Community 2019, an NVIDIA GeForce MX150 GPU, CUDA 10.2, cuDNN 7.6.5.32, and OpenCV 4.1.2.

i found a difference between Debug and Release version which is under the Debug version the macro definition OPENCV is not defined but under the Release version the OPENCV is defined.

could you share your solution to this issue if you hav saved it.
Thanks so much.

July

Hi July.

I took another look at darknet and noticed that indeed the “Release x64” version of darknet has a Preprocessor Definition “OPENCV”, and the “Debug x64” version does not. I tried adding “OPENCV” as a preprocessor definition in the “DEBUG x64”, but the debug version did not compile any better as a result. My instinct is that the issue has to due with an nvcc running into errors when it attempts to compile darknet’s CUDA files, but I’m not sure what those errors are. Any luck yourself?

Tom