Sunday, September 8, 2019

Deep learning in Ubuntu: installing darknet

This document describes how I added the darknet components to my Ubuntu deep learning machines.

Darknet is an open source environment for neural networks, written in C, by Joseph Redmon, aka pjreddie.
Darknet is very fast.


This document describes the installation of darknet on top of an ubuntu 18.04 linux machine,
equipped with a NVIDIA GPU board, where CUDA and OPENCV have been installed
(see these: NVIDIA and CUDA Setup and OPENCV setup).
The installation process is relying on Darknet setup instructions, but for my environment required some additional steps.

working in user mode, I create a darknet folder in my home

$mkdir darknet
$cd darknet
$git clone
$cd darknet

Edit the Makefile, adjusting options GPU=1 and OPENCV=1

then running make


it chokes giving many errors like

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

Examining the Makefile, you can see that it uses the commands

pkg-config --libs opencv


pkg-config --cflags opencv

1) install apt-file and update its library

#apt install apt-file
#apt-file update

2) look which package provides the file opecv.pc

#apt-file search opencv.pc
libopencv-dev: /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc

3) install libopecv-dev

#apt install libopencv-dev

4) re-executing make, which now does not give any more errors...

$cd darknet/darknet

5) and finally now you can see the eagles...

$./darknet imtest data/eagle.jpg

A potentially useful tool for showing pictures from command line is feh. It allows zoom and it is very handy.

No comments: