Darknet on Macos with GPU and OpenCVLast update: 9 months ago Tag : darknet, ml, dl, macos, hackintosh
Darknet here is not the dark web which requires you to open it with onion browser. It is an open source neural network framework written in C and CUDA. It is fast, easy to install, and supports CPU and GPU computation.
Well, not so easy to install actually, because you need to install opencv and cuda/cudnn first, which is very frustrating, and the google-fu says so, alot of problems when you compile it with opencv.
So, also from Google-Fu, I finally managed to compile the darknet with cuda and opencv supports, and here is the steps:
- Make sure to install the cuda and cudnn with CLT 8.3.2,and python3 using
- Compile and install opencv version 3.4.0, using:
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
- Fetch the version 3.4.0 from above both opencv:
cd opencv && git checkout 3.4.0
cd ../opencv_contrib && git checkout 3.4.0 && cd ../opencv
- Generate config and then compile:
mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -DPYTHON_LIBRARY=/usr/local/lib/libpython3.6.dylib \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON -DBUILD_opencv_python3=ON .. make -j8 make install
- Get darknet:
git clone https://github.com/pjreddie/darknet.git
Makefileand change GPU=1, CUDNN=1 and OPENCV=1
make -j8and wait til finish, maybe 1 or 2 hours later.
- Once finished, you can see an executable file
./darknetso you can continue to copy/paste the sample command to try.
Here is the sample:
It is also able to detect some objects in realtime using the webcam, although the framerate is just around 7-10 fps, it's still awesome!