Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get cmake to enable cuda when compiling yolo (darknet)?

I am currently using the cmake-gui to compile yolo darknet at https://github.com/AlexeyAB/darknet.git. However, it will not enable cuda and I am having a few other odd issues. These include when I run darknet.exe from the Release folder after building it using VS2017, it states that it cannot find pthreadVC2.dll or opencv_world410.dll.

To fix the other issues, I copied the exe and those files and put them all in the root folder of the project. This seems to work but I am not sure why it wouldn't work otherwise.

For cuda, I am not sure what to try. I have these system variables and path: System Variables System Variable Path

Here is my cmake-gui: cmake1 cmake2

It can be seen that CMAKE_CUDA_COMPILER is NOTFOUND. Which I am thinking is the problem, but I am not sure why it cannot be found. If I run nvcc -V in the command prompt, it returns:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130

Also here is the output for cmake configuration:

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
OpenCV ARCH: x64
OpenCV RUNTIME: vc15
OpenCV STATIC: OFF
Found OpenCV 4.1.0 in C:/opencv/build/x64/vc15/lib
You might need to add C:\opencv\build\x64\vc15\bin to your PATH to be able to run your applications.
ZED SDK not enabled, since it requires CUDA
Configuring done

If you have any tips for any of these problems, please let me know. Just an FYI, currently darknet does work and if I test it on dog.jpg, it successfully detects the classes. However, this is of course without Cuda or cudnn and I would like to use these eventually. Thank you! If you need anything else from me please let me know!

like image 878
Jacob Bunzel Avatar asked Apr 24 '19 12:04

Jacob Bunzel


2 Answers

Unlike above said, i didn't reinstall CUDA, i just copy 4 files from

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\visual_studio_integration\MSBuildExtensions

to

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations

like image 137
Wade Wang Avatar answered Sep 23 '22 09:09

Wade Wang


The answer was given by @Andropogon: CUDA has to be reinstalled after Visual Studio.

This is what we found when I dug into it a bit with my colleague:

  1. Similar to OP, all compilation steps seemed to run without error and generate an executable.
  2. Taking a closer look at cmake, under CMAKE/CMAKE_CUDA_COMPILER it said NOT FOUND, despite nvcc.exe being on the Path. (nvcc --version runs fine in Powershell.) We manually entered the location of nvcc.exe to this option, and now configure comes up with a more helpful error message: No CUDA toolset found. with reference to line numbers in various cmake files. Among those lines was this message, which seems to confirm that Visual Studio (VS) is part of the problem,
    if(NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA)
            message(FATAL_ERROR "No CUDA toolset found.")

So after reinstalling CUDA the compilation looked more like I would expect - but I still get an executable which doesn't appear to do anything (no output on the command line, no prediction.jpg generated). Anyway, hopefully that can shed a bit of light on the CUDA/VS/cmake issue.

like image 42
craq Avatar answered Sep 19 '22 09:09

craq