This is post #3 of a 5-part series on Darknet. If you've not yet read the summary, I suggest you start there.
Darknet is a command-line tool used to train and test neural networks. It is free, in every sense of the word.
The original Darknet repository hasn't been updated in several years. The web site has a little bit of information, and points to the repo on GitHub.
Instead, I recommend one of the many forks to the original Darknet. Specifically, I use the popular fork by AlexeyAB, available here. It contains some significant updates. It is important to note that it also differs from the original Darknet, so beware if you are following old tutorials for Darknet. For example, AlexeyAB's fork and the original Darknet do not handle labels the same way.
To get and build AlexeyAB's fork of Darknet, run the following commands:
If this doesn't work, stop here and check your development environment, there is no use continuing with this post if you cannot build the vanilla version of Darknet.
Next thing we're going to do is enable a few flags in the Makefile and build again. Edit ~/darknet/Makefile and change these lines near the top of the file:
Re-run make to see if this still works. In the end, you should have a darknet and libdarknet.so file.
If you have a Nvidia GPU and have installed the CUDA sdk, then we can tell Darknet to take advantage of the GPU. Edit the makefile one last time, and make the following additional edits:
You'll immediately know if you don't have the CUDA sdk installed, because the build will fail with errors related to the CUDA runtime:
If you are using CUDA, remember to add both /usr/local/cuda/bin and /usr/local/cuda/NsightCompute... to your path, as well as /usr/local/cuda/lib64 to LD_LIBRARY_PATH. For those of you like myself using fish, here are the commands I ran:
Running Darknet on the CPU to train a network is extremely slow. I would even call it unusable to train a decent network. What takes days on a CPU can be done in minutes or a few short hours with a GPU. Once the network is trained, then you can use it on a system with just a CPU, but for training you really need access to a system with a GPU and the CUDA sdk. Amazon EC2 is a great resource.
Once you have Makefile configured correctly, run the following commands:
You should now have the file ~/darknet/darknet, and when you run it without any parameters, you'll see this:
Go to post #4 of the series to train a neural network with Darknet.