Analytics Vidhya
Published in

Analytics Vidhya

Installing Darknet on Windows


What is Darknet? For those who aren’t familiar, Darknet is an open-source framework that supports Object Detection and Image Classification tasks in the form of Convolutional Neural Networks. Darknet is mainly known for its implementation of the YOLO algorithm (You Only Look Once), which has demonstrated state of the art performance when it comes to real-time object detection.

YOLOv3 object detection example from

Chances are if you want to create real-time object detection models on your webcam or video recording, you might want to consider using the YOLOv3 algorithm that is located in this framework. That being said, onto the main purpose of this article.

As anyone who owns a Windows PC knows, it can be a pain to set up applications and development environments. I wanted to provide some advice from my personal experience trying to install Darknet on my Windows 10 laptop.

First and foremost, PLEASE INSTALL APPLICATIONS IN THE CORRECT ORDER. I am speaking from experience when I say that it can be a nightmare if you don’t follow this golden rule. Also, this is my recommendation for installing darknet and it may or may not work for you. Full disclaimer.

The original GitHub repository for Darknet is here; however, we will be using AlexeyAB’s version which is an exact copy of Darknet with additional Windows support.


Requirements for darknet taken from

I will assume that you have a GPU that has a compute compatibility version greater than 3.0. (Check if your GPU is good at this link.)

The First Step is OpenCV

OpenCV was a nightmare for me but hopefully, it won’t be a pain for you. I used this tutorial to get OpenCV4. I will give a brief walkthrough and some advice.

Before downloading Visual Studio 2017, check if your PC has Visual Studio 2019 already installed. This will affect your 2017 installation since the Microsoft Visual C++ Redistributable for 2017 will not be downloaded due to the presence of more recent Redistributables on your PC. (The 2019 ones). So my advice is to uninstall Visual Studio 2019 and verify whether the 2019 Redistributables are still present in your PC’s Programs and Features. If it is then kindly uninstalling 2019’s x86 and x64 versions will fix this.

Verify you have these after VS Studio 2017 download

Remember to add CMake to your system PATH. If you forget to do so, you can add {LOCATION OF CMAKE FOLDER}\bin to your System Path in the Environment variables. An example CMake path is C:\Program Files\CMake\bin. If you do not know how to edit the System Path, please refer to this link.

Likewise, if you forget to add Anaconda to your System Path, simply add {LOCATION OF ANACONDA FOLDER}\Scripts to your System Path. An example is D:\Anaconda3\Scripts.

The code provided in the tutorial is only available from signing up for the author’s newsletters. So when you see the popup below, please click “Download Code” and sign up. You don’t pay anything and you can honestly unsubscribe after you get what you need. I don’t know the author nor am I trying to promote his newsletter, however, it is a massive timesaver.

Access to the installation scripts in the tutorial

I tried for 2 days with a different installation guide so trust me when I say it’s a lifesaver. Once you tested that OpenCV4 is working, congratulations you passed the hardest part of the installation!

The Second Step is CUDA

I will make your life very simple. Click this link and select Download. Of course, if you have Windows 7 or 8 then change the Version.

CUDA 10.0 Download for Windows 10

Once you run the installer, just keep clicking Next and verify that you do not encounter the screen below while installing.

Your Visual Studio 2017 did not install properly

If it did then you need to uninstall Visual Studio 2017 and redownload. If you did not encounter the message above and CUDA was successfully installed then you can move on to the next part!

The Third Step is getting CuDNN

To download CuDNN please click this link. You will need to register for an Nvidia Developer account before getting CuDNN. Once you register, agree to the terms and conditions and click the installer as shown in the screenshot below.

Once the file has been downloaded, extract the contents directly to your C drive. Once you have finished extracting, verify that the Cuda folder exists in your C drive as shown below.

Checking for Cuda folder presence

After that open up your environment variables, and add C:\cuda\bin as a new entry to your System Path. Congratulations you have installed the major requirements!!

The Fourth Step is getting vcpkg

The link to get the vcpkg library manager is here.

You can download the zip file for vcpkg as shown below.

Downloading vcpkg zip file

Once downloaded, extract the contents to a location of your choice. After that, open up a Command Prompt and navigate to the vcpkg folder. Once in, run the command:


After this bat file is finished its execution, run the command below:

vcpkg integrate install

After running these commands successfully, please open your Environment variables and Click “New” in the System Variables section.

New system variable

Name the new variable, VCPKG_ROOT and make it point the location of the vcpkg folder.

Also, define another system variable named VCPKG_DEFAULT_TRIPLET and set its value to x64-windows.

Open a Powershell window and type the commands below to prepare vcpkg for the darknet installation.

PS \>                  cd $env:VCPKG_ROOT
PS Code\vcpkg> .\vcpkg install pthreads opencv[ffmpeg]

Final Step is getting and installing Darknet

The moment we all were waiting for is finally here! Navigate to this link for the darknet code. Once you download and extract it to a location of your choice, open a Powershell window in Administrator mode.

Navigate to the location of the darknet folder and before you can build it, you must ensure that you can execute Powershell scripts.

Run the command below to verify your execution permission level.


If this returns unrestricted then you are good to run the final command, however, if it is not then run the command below.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Select “A” or “Y” and then run the final command.


Once this finishes executing then your darknet repository should be installed. Congratulations!

Don’t forget to run the command below and type “A”.

Set-ExecutionPolicy -ExecutionPolicy Restricted

To test darknet, simply running the command below should yield some output without any errors.

darknet.exe detector test cfg/ cfg/yolov3.cfg yolov3.weights -thresh 0.25


Once again this isn’t a one size fits all solution, however, if it does work for you then I am very happy that I could help. If it doesn’t then please refer to this link to try installing darknet with Cmake-GUI instead.

To see the various possibilities for training available to this darknet framework, please refer to this link.

Thank you for reading all the way up to this point and hope this guide helped you to get darknet installed on your PC. Take care for now!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store