AlturosDestinations / Alturos.Yolo

C# Yolo Darknet Wrapper (real-time object detection)
MIT License
427 stars 132 forks source link

Initialization of YoloWrapper stuck when using GPU #168

Open lnx00 opened 3 years ago

lnx00 commented 3 years ago

Hello, when I try to use my GPU (RTX 3070) the program will get stuck while initializing the YoloWrapper. This is the only thing that will be output to the console:

The RAM usage goes up to ~2GB and then stays there.

I've installed CUDA 10.2 correctly and placed the cudnn64_7.dll into my x64 project folder. Here you can also see that CUDA is correctly installed:

This is the code that initializes the YoloWrapper:

The file names are correct, and they are stored at the correct location. When using the CPU everything works fine. I only have this problem when using my GPU.

grandprixgp commented 3 years ago

@lnx00 CUDA 10.2 doesn't support ampere (3000 series) and OpenCV 4.3 doesn't support ampere.

lnx00 commented 3 years ago

Damn, is there any workaround or alternative?

grandprixgp commented 3 years ago

Damn, is there any workaround or alternative?

I am working on building darknet and OpenCV for CUDA 11.2 (supports ampere) right now, I will get back to you with precompiled binaries if I'm successful.

Note: author of this library made the bad decision of calling the darknet compiled library yolo_cpp_dll_gpu.dll for CUDA enabled build and yolo_cpp_dll_cpu.dll for CUDA disabled build while also listing an absolute requirement of CUDA 10.2 in the README. Those should really be called darknet_gpu.dll and darknet_cpu.dll and refer to the darknet project for CUDA compatibility which would probably cut down on people getting confused about compatibility issues.

BergChristian commented 3 years ago

@grandprixgp really interested if you succeed to get the binaries!

grandprixgp commented 3 years ago

@grandprixgp really interested if you succeed to get the binaries!

sorry (@lnx00 too) I actually succeeded the next day but forgot about this issue! attached - note it will probably only work on ampere. yolo_cpp_dll_gpu.zip

also during this time @cenit (https://github.com/AlexeyAB/darknet/issues/7081#issuecomment-765887543) managed to get OpenCV 4.5 onto vcpkg which now means that building darknet with CUDA support for latest gen GPUs is trivial. before you'd have to build OpenCV from source (took me 6 hours on 5800X) a few times (fixing mistakes/flag issues each time).

BergChristian commented 3 years ago

Awesome! Thanks for sharing.

I guess I need to include cudnn64_8 instead of cudnn64_7 to make it work... I guess Alturos could be updated to check for version of card and CUDA installed and switch use of yolo_cpp_dll_gpu?

Annoying to have different versions depending on different cards but it seems that the only way forward ?

cenit commented 3 years ago

Hi! Isn't it possible to use Darknet as a CMake target in this project, and so be independent of CUDNN, library name, etc etc...? Happy to assist if you need help, and sorry for not knowing more your project You would also avoid distributing binaries, which are not so efficient in a git repository

Egzscure commented 3 years ago

I am having simular issues. It works with 2070 super but doesnt work with 3070ti. How do i fix it? it just gets stuck

grandprixgp commented 3 years ago

I am having simular issues. It works with 2070 super but doesnt work with 3070ti. How do i fix it? it just gets stuck

As diagnosed above this library ships with dependencies that don't support 3000 series GPUs. You need to rebuild darknet, OpenCV, etc w/ CUDA > 10.2.

Egzscure commented 3 years ago

I am having simular issues. It works with 2070 super but doesnt work with 3070ti. How do i fix it? it just gets stuck

As diagnosed above this library ships with dependencies that don't support 3000 series GPUs. You need to rebuild darknet, OpenCV, etc w/ CUDA > 10.2.

but i tried with your dll, and i installed cuda 11.2 (which should support ampere) and im still not beeing able to run :\ any tips, im kind of new in the machine learning field