Reference https://blog.csdn.net/dz4543/article/details/85255267
https://blog.csdn.net/sinat_35907936/article/details/82017127
cuda8.0 cudnn5.1 (cuda9.0 and above are not compatible with vs2017)
vs2017 (actually using the vs2015 version compiler V140 in vs2017)
1. Download yolov3 from github
git clone https://github.com/AlexeyAB/darknet.git
My installation location D: \ software_engineer \ darknet
2. yolo_v3 weights: https://pjreddie.com/media/files/yolov3.weights (this will be used later)
1. Go to the D: \ software_engineer \ darknet \ darknet \ build \ darknet folder, open darknet.vcxproj, and replace CUDA 10.0 "with CUDA 8.0 (8.0 is my cuda version, just replace it with your own), (some People are not CUDA 10.0, but CUDA9.1, and they are also replaced with their own version numbers)
If your vs version is vs2013, change 14.0 to 12.0 and V140 to V120 in the picture below
2. Then use vs2017 to open darknet.sln, do not upgrade
Change the project to Release x64. Then you need to redirect the project: right-click project-> redirect project
If it is VS2017, you need to modify the tool set (see 1.1 for downloading the tool set process), modify as follows: right-click project-> properties
If you did not choose this tool when installing vs2017, it does not matter, exit VS2017. Open Visual Studio Installer in the menu .
3. Configure opencv in the property sheet
4. Copy CUDA 8.0.props and other files
CUDA 8.0.props and other files are in the cuda installation directory. The default path of cuda is: C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ extras \ visual_studio_integration \ MSBuildExtensions,
Copy these four files to C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ v140 \ BuildCustomizations, this is the path after vs2017 is installed, otherwise the following error may be reported:
5. Open the darknet.h header file to see if there is a red wavy line in it. If you don't, you don't need to do this step
1. My include <pthread.h> error, can not find the header file, solution: right-click the project-"Manage NuGet package, search for pthread, then install
2. My include <cudnn.h> is also wrong, the solution is (provided that cudnn is installed correctly):
Include a directory and library directory in the property, the path is inside the cuda installation directory
Then the connector-"input, add cudnn.lib in additional dependencies
6. Build the project. After the build is successful, there are more darknet.exe and other files in the project directory × 64.
Then put the previously downloaded yolo_v3 weights file in the same folder as darknet.exe
Then find the path of darknet-master \ build \ darknet \ x64 \ darknet.exe on cmd D: \> cd D: \ darknet \ build \ darknet \ x64 mine is this. Then enter darknet.exe detector test data / coco.data yolov3.cfg yolov3.weights -i 0 -thresh 0.25 dog.jpg
Note: The following error may be encountered when compiling darknet
错误 MSB3721 The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\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 14.0\VC\bin\x86_amd64" -x cu -I\include -IC:\opencv_3.0\opencv\build\include -I..\..\include -I..\..\3rdparty\stb\include -I..\..\3rdparty\pthreads\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -I\include -I\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -DOPENCV -DCUDNN_HALF -DCUDNN -D_TIMESPEC_DEFINED -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_RAND_S -DGPU -DWIN32 -DNDEBUG -D_CONSOLE -D_LIB -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Fdx64\Release\vc140.pdb /FS /Zi /MD " -o x64\Release\activation_kernels.cu.obj "G:\daek\darknet-master\src\activation_kernels.cu"" exited with code 1. darknet C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 8.0.targets 712
This problem can be solved by deleting the two items shown in the figure below.