Closed Arcticold closed 5 years ago
You should compile OpenCV from source with CUDA support by using Cmake https://github.com/opencv/opencv/archive/3.3.0.zip
or just
change this line: https://github.com/AlexeyAB/darknet/blob/00e992a600ba781da635b4f75fc02b2458639c4e/include/yolo_v2_class.hpp#L167
to this
#if defined(TRACK_OPTFLOW) && defined(OPENCV) && defined(GPU_DISABLED)
and comment these lines: https://github.com/AlexeyAB/darknet/blob/00e992a600ba781da635b4f75fc02b2458639c4e/src/yolo_console_dll.cpp#L34-L38
Ah, thanks, I'll try compiling, because I definitely need GPU.
Ok, so I downloaded OpenCV 3.3.0 and built it from source with CMake. CUDA support is turned on as far as I can tell (config file and ticks at right places) and I've eliminated all the errors related to newer versions of CUDA, but no .lib files are built whatsoever. It says it has finished everything successfully.
@Arcticold
These lib-files opencv_cudaoptflow340.lib
should be here: C:\opencv_source\opencv\bin\lib\Release
Did you check this checkbox? Can you show such screenshot?
Ok, so I was being dumbed a bit and thought that CMake will build it for me, but instead I had to open the project with VS and build it from there, so it was a missed step from my part.
However, I've stumbled upon another problem. When I try to build, it fails roughly 3/4 of the projects and only succeeds a few. From the error logs, I think I found the issue:
nvcc fatal : Unsupported gpu architecture 'compute_20'
My GPU is GTX 1080, CUDA 10.0. I already had to change the .cmake files a bit, because it didn't like the CUDA settings for it, but I guess I'm still missing something.
Upon Configuring in CMake program, it gives this line
CUDA detected: 10.0
CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-D_FORCE_INLINES
so it looks like as if everything is fine. No problems during generation either, it's only during actual Building in VS when it starts complaining. https://github.com/opencv/opencv/issues/12786 says it's a configuration issue and that adding -DCUDA_ARCH_BIN=6.1 will fix it. Upon looking into OpenCVDetectCUDA.cmake, I could guess that it's already doing it
set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1")
Am I wrong or do I need to do something extra?
Should I maybe just use a newer OpenCV? I chose 3.3.0, because on the front page README it was linked so I figured I'll use what is suggested.
The changes I've already done are listed here in the answer: https://stackoverflow.com/questions/46584000/cmake-error-variables-are-set-to-notfound
@Arcticold
Set here 3.0 7.5
or just 3.0
OK, this did the trick partially. I now get .lib files, but not .dll files. It now succeeds roughly 3/4 of projects and fails the others. There seem to be linking errors now and they all seem different.
69> Creating library D:/UT/MSc/opencv-3.3.0/opencv/lib/Release/opencv_cudaoptflow330.lib and object D:/UT/MSc/opencv-3.3.0/opencv/lib/Release/opencv_cudaoptflow330.exp
69>cuda_compile_generated_farneback.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_56_tmpxft_00004c7c_00000000_11_farneback_compute_75_cpp1_ii_a93d669c referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
69>cuda_compile_generated_pyrlk.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_52_tmpxft_00004ba8_00000000_11_pyrlk_compute_75_cpp1_ii_0bf363a8 referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
69>cuda_compile_generated_tvl1flow.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_55_tmpxft_000018dc_00000000_11_tvl1flow_compute_75_cpp1_ii_02f263de referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
69>D:\UT\MSc\opencv-3.3.0\opencv\bin\Release\opencv_cudaoptflow330.dll : fatal error LNK1120: 3 unresolved externals
I have no clue what to even do about them.
Hey, any updates on that?
@Arcticold Hi,
Try to install OpenCV with CUDA by using VCPKG: https://github.com/AlexeyAB/darknet#how-to-compile-on-windows-using-vcpkg
.\vcpkg install pthreads opencv[cuda]
Hi! That actually worked quite nicely. I got the required .lib and .dll files. Had to get the opencv_world343 files separately though, but that was easy enough.
I'm now getting a new problem though But I used opencv[cuda] to install it, that should add CUDA support, right?
I've opened a ticket with VCPKG project in order to determine where the issue might be exactly.
Meanwhile, I tried installing darknet on a clean Win OS installation to get rid of all the conflicting versions of different softwares.
As expected, everything up to and including building darknet with build.ps1 script works. However, I can't build yolo_console_dll project in any way. It seems that there's a different build of darknet in build_win_release? The build folder contains the three projects as before, however, I cannot compile any of them. When I try to compile darknet.sln with Visual Studio 2015, it starts giving syntax errors for almost all the files in darknet project (there are thousands on syntax error lines). If I try to open the project with Visual Studio 2017, whether I upgrade it or not, it keeps telling me
Designtime build failed for project... configuration 'Release|x64'. IntelliSense might be unavailable. Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
Could yolo_console_dll also be built with the .ps1 script? I tried to take a look at it, but didn't really understand what initiates the process.
Also, nVidia has update CUDA to 10.1, so when I try to install CUDA 10, it comes down as 10.1. I changed the entries in darknet.vcxproj so that it would open. Could that also cause issues? It didn't cause issues with I built it with build.ps1 script though.
@Arcticold Hi,
Have you successfully installed MSVS2017, CUDA, cuDNN, OpenCV 3.4.5?
Can you build the latest versions of Darknet by using Cmake-gui? To compile by using Cmake-GUI follow: Configure -> Optional platform for generator (Set: x64) -> Finish -> Generate -> Open Project -> x64 & Release -> Build -> Build solution
Hi!
MSVS2017 - yes CUDA - 10.1 installed, yes cuDNN - installed as instructed per nVidia, yes OpenCV 3.4.5 - vcpkg reports opencv:x64-windows 3.4.3-7 installed
The Cmake-GUI fails at step Configure. After I've navigated to darknet's source folder and click Configure, it gives this error
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/CMakeDetermineSystem.cmake:99 (message): Could not find toolchain file: /scripts/buildsystems/vcpkg.cmake Call Stack (most recent call first): CMakeLists.txt:14 (project)
Configuring incomplete, errors occurred!
which is strange, because the VCPKG_ROOT environment variable is set.
PS C:\Users\Rasmus> cd $env:VCPKG_ROOT
PS C:\vcpkg> ls
Directory: C:\vcpkg
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 3/24/2019 6:28 PM buildtrees
d----- 3/24/2019 6:18 PM docs
d----- 3/24/2019 6:28 PM downloads
d----- 3/24/2019 6:26 PM installed
d----- 3/24/2019 6:28 PM packages
d----- 3/24/2019 6:18 PM ports
d----- 3/24/2019 6:21 PM scripts
d----- 3/24/2019 6:21 PM toolsrc
d----- 3/24/2019 6:18 PM triplets
-a---- 3/24/2019 6:18 PM 8 .gitattributes
-a---- 3/24/2019 6:18 PM 5584 .gitignore
-a---- 3/24/2019 6:18 PM 0 .vcpkg-root
-a---- 3/24/2019 6:18 PM 100 bootstrap-vcpkg.bat
-a---- 3/24/2019 6:18 PM 106 bootstrap-vcpkg.sh
-a---- 3/24/2019 6:18 PM 128706 CHANGELOG.md
-a---- 3/24/2019 6:18 PM 2432 CONTRIBUTING.md
-a---- 3/24/2019 6:18 PM 1107 LICENSE.txt
-a---- 3/24/2019 6:18 PM 3176 README.md
-a---- 3/24/2019 6:21 PM 936960 vcpkg.exe
@Arcticold Hi,
Just try to de-install VCPKG
download and un-pack OpenCV https://sourceforge.net/projects/opencvlibrary/files/3.4.5/opencv-3.4.5-vc14_vc15.exe/download
And set system variable OPENCV_DIR = C:\opencv\build
- where are the include and x64 folders image) https://user-images.githubusercontent.com/4096485/53249516-5130f480-36c9-11e9-8238-a6e82e48c6f2.png
As described here: https://github.com/AlexeyAB/darknet#requirements
Hi!
I tried scraping VCPKG off as much as I could. Also removed opencv[cuda] and pthreads packages installed with it prior. I downloaded and unpacked OpenCV from given link, changed the system variable, but everything is still the same.
"de-install" vcpkg is just a matter of removing the vcpkg folder and the VCPKG_ROOT environment variable you may have defined. No need to do anything else.
@Arcticold What do you mean that "you can't build yolo_console_dll project in any"? There are 4 targets of the project: 1) darknet.exe, the main executable 2) darklib.dll/lib, the main library 3) uselib, an executable that sets an example of using darklib 4) uselib_track, another executable which uses darklib and opencv[cuda] Which one is missing in your case?
I can't understand fully what you are experiencing, but I am almost sure you are mixing and matching many different things, installations and files, like I told you on vcpkg issue tracker . One example, for all, there is absolutely NO need to do what he said: "Had to get the opencv_world343 files separately though, but that was easy enough". OpenCV libraries are already built and ready to be used, do not download any other pre-built dll from anywhere!!
When you install OpenCV with vcpkg you just have to use it as it is, and like you said it should work quite nicely. It is deployed in production in many environment and is very robust. I fear that he has many OpenCV installations, and CMake is just pulling them and making many mistakes. Also the script stops with a hard error if the toolchain file is not found, so please remove any mod you may have done to the build.ps1 script. Just re-clone the repository from scratch in case you have any doubt, you may keep as many clones as you want.
Can I see the configure log of CMake (which means, the lines that it prints when you just launch .\build.ps1
)? Please delete build** folders before running the script.
Hi!
The end goal is to get the project yolo_console_dll to compile with tracking enabled and produce a working yolo_console_dll.exe. The project is located in darknet/build/darknet.
The opencv_world343 file I acquired separately, because it did not exist anywhere on my machine. I applied search on all relevant folders and disks and came out empty handed.
Anyways, I installed a fresh OS, so that got rid of all the potential version issues. I haven't had any issues with build.ps1 script, this thing is working fine. Currently the mistake I'm getting from CMake is this one:
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/CMakeDetermineSystem.cmake:99 (message):
Could not find toolchain file: /scripts/buildsystems/vcpkg.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (project)
Configuring incomplete, errors occurred!
I can get the log of CMake first thing in the morning, since it takes time to reinstall OpenCV via VCPKG. I'm currently trying without it though and I'm getting this error:
Remove-Item : Cannot find path 'C:\msc\darknet\build_win_release\DarknetConfig.cmake' because it does not exist
It doesn't seem like OpenCV related error though, but since the previously working conditions are not met right now, I'll look over this and report back with a complete log once I've re-installed previous conditions.
Here are the lines printed when I execute build.ps1 script: https://justpaste.it/4p6it
To me everything looks perfectly fine. You have your executables (uselib_track is your desired yolo_cpp_console) and libraries. By the way: of course you don’t find opencv_world. That is not necessary since you built opencv with vcpkg
The build.ps1 script and the resulting darknet.exe work fine. Currently there are no issues with them. The issues come when proceeding with yolo_console_dll project.
There is no yolo_console_dll project when using CMake! That’s a legacy project when using old solutions, as I am trying to say to you, look at uselib and uselib_track!!
Ok, I just checked and the uselib_track.exe appears to be what I wanted. I didn't realise that the project was renamed when you mentioned it before and thought it to be something else.
Speaking of that, uselib_track.exe plays the video file I'm giving it to extremely fast (FPS capture reports around 80) - way too fast for any normal working. uselib.exe also plays the video a bit too fast, but in normal levels. Should I open a separate issue about them or continue it here?
Open another issue and close this one
So it seems trivial, but I'm simply unable to locate the required libraries for yolo_console_dll.cpp file. When I uncomment TRACK_OPTFLOW, it requires certain files
I've looked into OpenCV folders, CUDA folders and so on, but those libraries just don't exist anywhere on my PC. Where can one find these?