AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.69k stars 7.96k forks source link

OpenCV 4.3 package does not support CUDA 11 on RTX 30 series GPUs #7081

Closed ROBYER1 closed 3 years ago

ROBYER1 commented 3 years ago

I am unable to install using the vcpkg instructions here due to the RTX 3080 card requiring CUDA 11 and 'opencv[core,cuda,dnn,ffmpeg,jpeg,opengl,png,tiff,webp]:x64-windows -> 4.3.0' does not support CUDA 11

Leaving me with the error:

  • nvcc fatal : Unsupported gpu architecture 'compute_30'

I checked the cmake file for opencv4.3 and it doesn't even mention compute_30 in the CUDA_ARCH section so that's ringing alarm bells.

Read more about this issue here: https://github.com/microsoft/vcpkg/issues/12620

Supported GPU compute version list: http://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/

Is there a fix or workaround?

ROBYER1 commented 3 years ago

This may come down to vcpkg not implementing OpenCV 4.4 or 4.5 yet.

I think the vcpkg install instructions are great and so simple for Windows, after trying to do all the installation building from source which took hours and was a pain.

Will vcpkg automatically use the newest version of OpenCV without me needing to change anything once they have updated it to 4.4/4.5?

JackBoosY commented 3 years ago

@ROBYER1 I hope too.

bulatnv commented 3 years ago

Hello @ROBYER1, @JackBoosY I have successfully installed darknet on Windows with 3090. First of all do everything from scratch. Uninstall old CUDA, cuDNN, clear all %PATH% variables.

For Ampere install latest driver 450+, install at least CUDA 11.1, cuDnn 8.0+, then build from scratch vpkg, darknet. I have used: 1) cuda_11.1.0_456.43_win10 2) cudnn-11.1-windows-x64-v8.0.4.30

How to properly install vcpkg:

PS Code\>              git clone https://github.com/microsoft/vcpkg
PS Code\>              cd vcpkg
PS Code\vcpkg>         $env:VCPKG_ROOT=$PWD
PS Code\vcpkg>         .\bootstrap-vcpkg.bat 
PS Code\vcpkg>         .\vcpkg install darknet[opencv-base,cuda,cudnn]:x64-windows #replace "full" with "opencv-base,cuda,cudnn"
PS Code\vcpkg>         cd ..

Then download darknet:

PS Code\>              git clone https://github.com/AlexeyAB/darknet
PS Code\>              cd darknet

before building darknet change "Makefile" file (enable CUDA, cuDNN, opencv and change architecture):

GPU=1
CUDNN=1
OPENCV=1
# ARCH= -gencode arch=compute_35,code=sm_35 \
#       -gencode arch=compute_50,code=[sm_50,compute_50] \
#       -gencode arch=compute_52,code=[sm_52,compute_52] \
#       -gencode arch=compute_61,code=[sm_61,compute_61]

ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]

Then build darknet:

PS Code\darknet>       .\build.ps1

Best of luck. ;)

ROBYER1 commented 3 years ago

Hello @ROBYER1, @JackBoosY I have successfully installed darknet on Windows with 3090. First of all do everything from scratch. Uninstall old CUDA, cuDNN, clear all %PATH% variables.

For Ampere install latest driver 450+, install at least CUDA 11.1, cuDnn 8.0+, then build from scratch vpkg, darknet. I have used:

  1. cuda_11.1.0_456.43_win10
  2. cudnn-11.1-windows-x64-v8.0.4.30

How to properly install vcpkg:

PS Code\>              git clone https://github.com/microsoft/vcpkg
PS Code\>              cd vcpkg
PS Code\vcpkg>         $env:VCPKG_ROOT=$PWD
PS Code\vcpkg>         .\bootstrap-vcpkg.bat 
PS Code\vcpkg>         .\vcpkg install darknet[opencv-base,cuda,cudnn]:x64-windows #replace "full" with "opencv-base,cuda,cudnn"
PS Code\vcpkg>         cd ..

Then download darknet:

PS Code\>              git clone https://github.com/AlexeyAB/darknet
PS Code\>              cd darknet

before building darknet change "Makefile" file (enable CUDA, cuDNN, opencv and change architecture):

GPU=1
CUDNN=1
OPENCV=1
# ARCH= -gencode arch=compute_35,code=sm_35 \
#       -gencode arch=compute_50,code=[sm_50,compute_50] \
#       -gencode arch=compute_52,code=[sm_52,compute_52] \
#         -gencode arch=compute_61,code=[sm_61,compute_61]

ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]

Then build darknet:

PS Code\darknet>       .\build.ps1

Best of luck. ;)

Confirmed this builds with CUDA support yes?

I think somebody should make a PR of this make file change, didn't realise it was that simple!

In the end I built OpenCV 4.5.0 from source with CUDA support as the current latest available vcpkg version is 4.3 from what I could see which doesn't support CUDA 11

JackBoosY commented 3 years ago

cc @cenit

pplxlee commented 3 years ago

Hello @ROBYER1, @JackBoosY I have successfully installed darknet on Windows with 3090. First of all do everything from scratch. Uninstall old CUDA, cuDNN, clear all %PATH% variables.

For Ampere install latest driver 450+, install at least CUDA 11.1, cuDnn 8.0+, then build from scratch vpkg, darknet. I have used:

  1. cuda_11.1.0_456.43_win10
  2. cudnn-11.1-windows-x64-v8.0.4.30

How to properly install vcpkg:

PS Code\>              git clone https://github.com/microsoft/vcpkg
PS Code\>              cd vcpkg
PS Code\vcpkg>         $env:VCPKG_ROOT=$PWD
PS Code\vcpkg>         .\bootstrap-vcpkg.bat 
PS Code\vcpkg>         .\vcpkg install darknet[opencv-base,cuda,cudnn]:x64-windows #replace "full" with "opencv-base,cuda,cudnn"
PS Code\vcpkg>         cd ..

Then download darknet:

PS Code\>              git clone https://github.com/AlexeyAB/darknet
PS Code\>              cd darknet

before building darknet change "Makefile" file (enable CUDA, cuDNN, opencv and change architecture):

GPU=1
CUDNN=1
OPENCV=1
# ARCH= -gencode arch=compute_35,code=sm_35 \
#       -gencode arch=compute_50,code=[sm_50,compute_50] \
#       -gencode arch=compute_52,code=[sm_52,compute_52] \
#         -gencode arch=compute_61,code=[sm_61,compute_61]

ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]

Then build darknet:

PS Code\darknet>       .\build.ps1

Best of luck. ;)

It works for me! Thank you so match! I think the key is installing opencv-base and changing "Makefile".

cborelc commented 3 years ago

Hello @ROBYER1, @JackBoosY . I had the same problem and what you suggested worked for me to I have 2 GPU's a GTX1070 and GTX1080 using CUDA11. I changed the ARCH to:

_ARCH= -gencode arch=compute_61,code=[sm_61,compute61]

Unfortunately OpenCV does not work right now:

_PS D:\darknet\darknet> ./darknet detector valid cfg/coco.data cfg/yolov4.cfg yolov4.weights CUDA-version: 11020 (11020), cuDNN: 8.0.4, GPU count: 2 OpenCV isn't used - data augmentation will be slow results: Using default 'results' 0 : compute_capability = 610, cudnnhalf = 0, GPU: GeForce GTX 1080

JackBoosY commented 3 years ago

@cborelc Can you discuss this on microsoft/vcpkg#15162 ?

Thanks.

grandprixgp commented 3 years ago

Hello @ROBYER1, @JackBoosY I have successfully installed darknet on Windows with 3090. First of all do everything from scratch. Uninstall old CUDA, cuDNN, clear all %PATH% variables.

For Ampere install latest driver 450+, install at least CUDA 11.1, cuDnn 8.0+, then build from scratch vpkg, darknet. I have used:

1. cuda_11.1.0_456.43_win10

2. cudnn-11.1-windows-x64-v8.0.4.30

How to properly install vcpkg:

PS Code\>              git clone https://github.com/microsoft/vcpkg
PS Code\>              cd vcpkg
PS Code\vcpkg>         $env:VCPKG_ROOT=$PWD
PS Code\vcpkg>         .\bootstrap-vcpkg.bat 
PS Code\vcpkg>         .\vcpkg install darknet[opencv-base,cuda,cudnn]:x64-windows #replace "full" with "opencv-base,cuda,cudnn"
PS Code\vcpkg>         cd ..

Then download darknet:

PS Code\>              git clone https://github.com/AlexeyAB/darknet
PS Code\>              cd darknet

before building darknet change "Makefile" file (enable CUDA, cuDNN, opencv and change architecture):

GPU=1
CUDNN=1
OPENCV=1
# ARCH= -gencode arch=compute_35,code=sm_35 \
#       -gencode arch=compute_50,code=[sm_50,compute_50] \
#       -gencode arch=compute_52,code=[sm_52,compute_52] \
#         -gencode arch=compute_61,code=[sm_61,compute_61]

ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]

Then build darknet:

PS Code\darknet>       .\build.ps1

Best of luck. ;)

This does nothing more than build with OpenCV 4.3 which again, doesn't support CUDA 11+ and thus doesn't support ampere.

cenit commented 3 years ago

My pr on opencv 4.5 is progressing nicely finally. I hope for a quick merge and then update here ASAP

grandprixgp commented 3 years ago

My pr on opencv 4.5 is progressing nicely finally. I hope for a quick merge and then update here ASAP

In the mean time I'm pulling my hair out stuck on this build error (after defeating all the other dragons..): >nvcc fatal : Don't know what to do with 'C:/vcpkg/scripts/buildsystems/msbuild/../../../installed/x64-windows/lib/OpenGL32.Lib'

The error code is MSB3721. Any ideas?

Edit: you won't believe this, it was the fact that the extension was .Lib and not .lib..... that's a vcpkg bug as far as I can tell. I can't believe it.

cenit commented 3 years ago

By the way, modifying makefile and then using build.ps1 is totally unnecessary, because build.ps1 (and build.sh) uses CMakeLists.txt and not makefile....

cenit commented 3 years ago

My pr on opencv 4.5 is progressing nicely finally. I hope for a quick merge and then update here ASAP

In the mean time I'm pulling my hair out stuck on this build error (after defeating all the other dragons..): >nvcc fatal : Don't know what to do with 'C:/vcpkg/scripts/buildsystems/msbuild/../../../installed/x64-windows/lib/OpenGL32.Lib'

The error code is MSB3721. Any ideas?

Edit: you won't believe this, it was the fact that the extension was .Lib and not .lib..... that's a vcpkg bug as far as I can tell. I can't believe it.

Can you put some context on it? OpenGL port on vcpkg for windows is just extracting lib files from windows sdk. Also, filesystem on windows must be case insensitive, otherwise the world falls apart, so .Lib or .lib should be the same

grandprixgp commented 3 years ago

By the way, modifying makefile and then using build.ps1 is totally unnecessary, because build.ps1 (and build.sh) uses CMakeLists.txt and not makefile....

Exactly, those instructions are bogus.

Can you put some context on it? OpenGL port on vcpkg for windows is just extracting lib files from windows sdk. Also, filesystem on windows must be case insensitive, otherwise the world falls apart, so .Lib or .lib should be the same

I can only imagine nvcc has a bug when parsing extensions of files passed into it where it is indeed case sensitive. Also why the extension is .Lib in the first place is confusing. I'll look at it some more tomorrow though.. all I know is that I figured it can't hurt to rename, swapped OpenGL32.Lib to OpenGL32.lib, and it then complained about GLU32.Lib, which I renamed to GLU32.lib - build success. Tomorrow I can find the full error for you, but it's just one massive nvcc command with all of the libs being passed in.

cenit commented 3 years ago

yes please, so that I can fix it in vcpkg if that's the case

ROBYER1 commented 3 years ago

yes please, so that I can fix it in vcpkg if that's the case

I now run into this error, maybe update the readme with proper instructions? Tested on a brand new windows install as I needed to reinstall, even after adding Ninja, the vcpkg install doesn't find OpenCV installed by vcpkg https://github.com/AlexeyAB/darknet/issues/7273

grandprixgp commented 3 years ago

yes please, so that I can fix it in vcpkg if that's the case

I now run into this error, maybe update the readme with proper instructions? Tested on a brand new windows install as I needed to reinstall, even after adding Ninja, the vcpkg install doesn't find OpenCV installed by vcpkg

7273

just to confirm you are talking about the error in that issue and not the error me and @cenit were discussing?

@cenit I should have time to take another look at that weird (potential) vcpkg issue tomorrow

cenit commented 3 years ago

My pr on opencv 4.5 is progressing nicely finally. I hope for a quick merge and then update here ASAP

OpenCV 4.5 is finally available on vcpkg https://github.com/microsoft/vcpkg/pull/15162. There is a PR here to fix a problem with Ninja #7279 , that will be merged very soon, afterwards please let me know your results :)