Compile and run https://github.com/AlexeyAB/darknet for Windows. Makes it easy to start with. Ideal for beginners.
- Make sure you have Visual Studio 2022 or newer installed. All editions (community, professional, etc.) will work. Make sure you have installed the C++ and C# (.NET 6) workloads with it.
- Make sure you have git installed: https://git-scm.com/download/win.
- Make sure you have Powershell or Pwsh installed. Powershell is already part of Windows 10 or newer. So most users wont need this step. You can download it here: https://github.com/PowerShell/PowerShell
- Check out this repository
- Run
bootstrap.ps1
. This will compiledarknet.dll
anddarknet.exe
(if you prefer command line) in both x86 and x64 under \bin\x86\ and \bin\x64
5.1 If you want to use CUDA/CUDNN, runbootstrap.ps1 -cuda [[sm_]<Number>] [-cudnn]
, e.g.:
bootstrap.ps1 -cuda
(translates to 'bootstrap.ps1 -cuda sm_52')
bootstrap.ps1 -cuda sm_35
bootstrap.ps1 -cuda -cudnn
(translates to 'bootstrap.ps1 -cuda sm_52 -cudnn')
bootstrap.ps1 -cuda sm_52 -cudnn
bootstrap.ps1 -cuda 72 -cudnn
(translates to 'bootstrap.ps1 -cuda sm_72 -cudnn')
This will compile the x64 version of darknet with CUDA. x86 is not supported and will fallback to the version as if it was not compiled with the -cuda flag. Selectsm_<Number>
based on your graphics card.
5.2 If you compile with -cuda (optionally with -cudnn) please follow the install instructions for CUDA/CUDNN below. - Open
src\Detect\Detect.sln
with Visual Studio and run. You will be ask to choose an image to detect objects on. Try a picture with people or cars on it. If you have builtdarknet.dll
without-cuda
, detection might take minutes!
- Make sure you have an internet connection while running
bootstrap.ps1
. It will download all necessary tools to compiledarknet.dll
. - The compiled
darknet.dll
does require Microsoft Visual C++ Redistributable package. It is installed with Visual Studio by default. You can download it here: https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
-
Download Nvidia CUDA Tookit (~2 to ~3 GB) https://developer.nvidia.com/cuda-downloads. I did the 11.7 version.
-
Run the Nvidia CUDA Tookit Installer, select custom install to choose only
CUDA
. You are free to install all the software the installer offers, but for now we don't need Audio Drivers, Graphics or Physics! -
While installing, Nvidia CUDA Toolkit will check, if you have Visual Studio installed and will install proper Visual Studio references for you. These are not necessary for this project, but will help you creating CUDA applications with Visual Studio.
-
Download CUDNN. Either register with Nvidia to get the latest version of CUDNN or download one of the archive versions. Make sure the major version of CUDNN matches the major version of CUDA. So if you have installed CUDA 11.7, you have to download CUDNN for CUDA 11.x https://developer.nvidia.com/rdp/cudnn-archive. For me it said 'Download cuDNN v8.4.1 (May 27th, 2022), for CUDA 11.x'
-
After download, extract the CUDNN zip archive, and copy all contents where you want. I copied all to the folder, where the CUDA Toolkit was installed. But instead of copying them into the CUDA folder, I created a separate folder named
CUDNN
next to theCUDA
folder.
-
Into that folder copy all folders you extracted from the CUDNN zip file:
-
Create the environment variable
CUDNN
pointing to the folder we just created: