DarkNet Training

Hi, Today I would like to announce that my GitHub fork at https://github.com/sowson/darknet has a new update. The fork is an advanced port of DarkNet CNN from CUDA to OpenCL and tested on macOS with eGPU from Sonnet named Breakaway RX 570 Puck and on my GreenPC.

Let’s get started with the training by inspiring the solution original author Joseph Redmon gave the TED talk.

Interested in how it works and how to rebuild? Why I spent some time overnight changing it? Bear with me. The training has just begun.

This is some very beginning work I did. After changing DarkNet to run on macOS Sierra 10.13.3 when external GPU (eGPU) support was in the experimental stage. I bought Sonnet Breakaway RX 570 Puck, and my journey began.

UPDATE: 2021-02-27 setup for Ubuntu 20.04

sudo apt update
sudo apt upgrade
sudo apt install wget
sudo apt install net-tools
sudo apt install git
sudo apt install gfortran
sudo apt install cmake
sudo apt install valgrind
sudo apt install nano
sudo apt install libomp-dev
sudo apt install zlib1g-dev
sudo apt install libtiff-dev
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev python3-dev python3-numpy \
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
sudo dpkg ——add-architecture i386
sudo apt install linux-generic
sudo apt remove linux-image-`uname -r` linux-modules-`uname -r` linux-headers-`uname -r`
sudo reboot
wget ——referer=https://drivers.amd.com https://drivers.amd.com/drivers/linux/amdgpu-pro-20.45-1188099-ubuntu-20.04.tar.xz
tar -Jxvf amdgpu-pro-20.40-1147286-ubuntu-20.04.tar.xz
cd amdgpu-pro-20.45-1188099-ubuntu-20.04
./amdgpu-install -y ——opencl=rocr
sudo apt install libclblas-dev
git clone https://github.com/sowson/clBLAS clBLAS-2.12-sowson
cd clBLAS-2.12-sowson/src
mkdir build && cd build && cmake .. && make -j 16 && sudo cp library/libclBLAS.so.2.12.0 /usr/lib/x86_64-linux-gnu/libclBLAS.so.2.12.0 && cd .. && rm -r build
cd ~/github
git clone https://github.com/opencv/opencv
cd opencv
git checkout 3.4
mkdir build && cd build && cmake -DWITH_OPENCL -DCL_TARGET_OPENCL_VERSION=120 .. && make -j 16 && sudo make install > ~/opencv-install-out.txt && cd .. && rm -r build && cd
sudo apt install clinfo
git clone https://github.com/sowson/darknet darknet
cd darknet
# use sed or edit manually
cp Makefile Makefile.bak && cat Makefile.bak | sed ‘s/NVIDIA=1/NVIDIA=0/g’ | sed ‘s/AMD=0/AMD=1/g’ > Makefile
make
#clean up (optional)
rm -r amdgpu-pro-20.40-1147286-ubuntu-20.04
rm -r opencv-3.4.12
rm -r clBLAS-2.12-sowson

So how to make it works on macOS? Here is the command list updated Today.

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
# OpenCV2
brew install opencv@2
brew link ——force opencv@2
# OpenCV3 (if you do not want OpenCV2)
brew install opencv@3
brew link ——force opencv@3
brew install libomp
brew install clblas
brew install clfft
brew install cmake
brew install wget
mkdir github; cd github; git clone https://github.com/sowson/darknet.git
cd darknet; mkdir build; cmake -Bbuild -H.; cd build; make; cd ..; cp build/darknet .; rm -r build

But, I also have GreenPC, quite a powerful workstation, so I installed on separated SDD the CentOS GNU/Linux on it, and to set it up quickly, all you need here is the commands list. Caution! It is the REBOOT command in the middle.

su –
yum install epel-release
yum upgrade
yum install wget
wget http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-9.1.85-1.x86_64.rpm
rpm -i cuda-repo-rhel7-9.1.85-1.x86_64.rpm
yum clean all
yum install cuda
reboot
su –
yum install clinfo
clinfo
yum install cmake
yum instsall gcc-gfortran
yum install boost
wget https://github.com/clMathLibraries/clBLAS/releases/download/v2.12/clBLAS-2.12.0-Linux-x64.tar.gz
tar zxf clBLAS-2.12.0-Linux-x64.tar.gz
cd clBLAS-2.12.0-Linux-x64
cp bin/* /usr/bin/
cp lib64/* /usr/lib64/
cp -r lib64/cmake/* /usr/lib64/cmake/
cp -r lib64/pkgconfig/* /usr/lib64/pkgconfig/
cp -r include/* /usr/include/
yum install git
yum install opencv-devel
yum install openmpi-devel
exit
mkdir github; cd github; git clone https://github.com/sowson/darknet.git
cd darknet; make

The answer to the question of how to play with it is on the video at the beginning. Remember to understand recurrent; you need to first understand recurrent. Thank you for reading and watching.

p ;).

29 Replies to “DarkNet Training”

    • Thanks, Imagine also Raspberry Pi and VC4CL and for example AI classifier for Home Sensors. Could be awesome!

  1. Excellent work!. I followed the Mac OS tutorial, but when i run the command “cd darknet; mkdir build; cmake -Bbuild -H.; cmake –build build; cp build/darknet .; rm -r build”. This is my result:

    — The C compiler identification is AppleClang 9.1.0.9020039
    — The CXX compiler identification is AppleClang 9.1.0.9020039
    — Check for working C compiler: /usr/bin/gcc
    — Check for working C compiler: /usr/bin/gcc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info -- done
    — Detecting C compile features
    — Detecting C compile features -- done
    — Check for working CXX compiler: /usr/bin/g++
    — Check for working CXX compiler: /usr/bin/g++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info -- done
    — Detecting CXX compile features
    — Detecting CXX compile features -- done
    — Looking for CL_VERSION_2_2
    — Looking for CL_VERSION_2_2 -- not found
    — Looking for CL_VERSION_2_1
    — Looking for CL_VERSION_2_1 -- not found
    — Looking for CL_VERSION_2_0
    — Looking for CL_VERSION_2_0 -- not found
    — Looking for CL_VERSION_1_2
    — Looking for CL_VERSION_1_2 -- found
    — Found OpenCL: /System/Library/Frameworks/OpenCL.framework (found version “1.2”)
    — Configuring done
    — Generating done
    — Build files have been written to: /Users/ricardoramirez/workspace/yolo/sowson/darknet/build
    — Configuring done
    — Generating done
    — Build files have been written to: /Users/ricardoramirez/workspace/yolo/sowson/darknet/build
    cp: build/darknet: No such file or directory

    Thanks you very much for your work in advance!.

  2. Please, try (inside a cloned folder):

    mkdir b; cd b; cmake ..; make; cp darknet ..; cd ..; rm -r b

    Thanks!

    • Thanks for your response! This is the output of that command:

      MacBookProGE:darknet ricardoramirez$ mkdir b; cd b; cmake ..; make; cp darknet ..; cd ..; rm -r b
      — The C compiler identification is AppleClang 9.1.0.9020039
      — The CXX compiler identification is AppleClang 9.1.0.9020039
      — Check for working C compiler: /usr/bin/gcc
      — Check for working C compiler: /usr/bin/gcc — works
      — Detecting C compiler ABI info
      — Detecting C compiler ABI info -- done
      — Detecting C compile features
      — Detecting C compile features -- done
      — Check for working CXX compiler: /usr/bin/g++
      — Check for working CXX compiler: /usr/bin/g++ — works
      — Detecting CXX compiler ABI info
      — Detecting CXX compiler ABI info -- done
      — Detecting CXX compile features
      — Detecting CXX compile features -- done
      — Looking for CL_VERSION_2_2
      — Looking for CL_VERSION_2_2 -- not found
      — Looking for CL_VERSION_2_1
      — Looking for CL_VERSION_2_1 -- not found
      — Looking for CL_VERSION_2_0
      — Looking for CL_VERSION_2_0 -- not found
      — Looking for CL_VERSION_1_2
      — Looking for CL_VERSION_1_2 -- found
      — Found OpenCL: /System/Library/Frameworks/OpenCL.framework (found version “1.2”)
      — Configuring done
      — Generating done
      — Build files have been written to: /Users/ricardoramirez/workspace/yolo/sowson/darknet/b
      Scanning dependencies of target bindarknet
      [ 0%] Building C object CMakeFiles/bindarknet.dir/src/activation_layer.c.o
      [ 0%] Building C object CMakeFiles/bindarknet.dir/src/activations.c.o
      [ 1%] Building C object CMakeFiles/bindarknet.dir/examples/art.c.o
      [ 1%] Building C object CMakeFiles/bindarknet.dir/examples/attention.c.o
      [ 2%] Building C object CMakeFiles/bindarknet.dir/src/avgpool_layer.c.o
      [ 2%] Building C object CMakeFiles/bindarknet.dir/src/batchnorm_layer.c.o
      [ 2%] Building C object CMakeFiles/bindarknet.dir/src/blas.c.o
      [ 3%] Building C object CMakeFiles/bindarknet.dir/src/box.c.o
      [ 3%] Building C object CMakeFiles/bindarknet.dir/examples/captcha.c.o
      [ 4%] Building C object CMakeFiles/bindarknet.dir/examples/cifar.c.o
      [ 4%] Building C object CMakeFiles/bindarknet.dir/examples/classifier.c.o
      [ 5%] Building C object CMakeFiles/bindarknet.dir/examples/coco.c.o
      [ 5%] Building C object CMakeFiles/bindarknet.dir/src/col2im.c.o
      [ 5%] Building C object CMakeFiles/bindarknet.dir/src/compare.c.o
      [ 6%] Building C object CMakeFiles/bindarknet.dir/src/connected_layer.c.o
      [ 6%] Building C object CMakeFiles/bindarknet.dir/src/convolutional_layer.c.o
      [ 7%] Building C object CMakeFiles/bindarknet.dir/src/cost_layer.c.o
      [ 7%] Building C object CMakeFiles/bindarknet.dir/src/crnn_layer.c.o
      [ 7%] Building C object CMakeFiles/bindarknet.dir/src/crop_layer.c.o
      [ 8%] Building C object CMakeFiles/bindarknet.dir/src/data.c.o
      [ 8%] Building C object CMakeFiles/bindarknet.dir/src/deconvolutional_layer.c.o
      [ 9%] Building C object CMakeFiles/bindarknet.dir/src/demo.c.o
      [ 9%] Building C object CMakeFiles/bindarknet.dir/src/detection_layer.c.o
      [ 10%] Building C object CMakeFiles/bindarknet.dir/examples/detector.c.o
      [ 10%] Building C object CMakeFiles/bindarknet.dir/examples/dice.c.o
      [ 10%] Building C object CMakeFiles/bindarknet.dir/src/dropout_layer.c.o
      [ 11%] Building C object CMakeFiles/bindarknet.dir/src/gemm.c.o
      [ 11%] Building C object CMakeFiles/bindarknet.dir/examples/go.c.o
      [ 12%] Building C object CMakeFiles/bindarknet.dir/src/gru_layer.c.o
      [ 12%] Building C object CMakeFiles/bindarknet.dir/src/im2col.c.o
      [ 13%] Building C object CMakeFiles/bindarknet.dir/src/image.c.o
      [ 13%] Building C object CMakeFiles/bindarknet.dir/src/iseg_layer.c.o
      [ 13%] Building C object CMakeFiles/bindarknet.dir/examples/instance-segmenter.c.o
      [ 14%] Building C object CMakeFiles/bindarknet.dir/src/layer.c.o
      [ 14%] Building C object CMakeFiles/bindarknet.dir/src/list.c.o
      [ 15%] Building C object CMakeFiles/bindarknet.dir/src/local_layer.c.o
      [ 15%] Building C object CMakeFiles/bindarknet.dir/src/lstm_layer.c.o
      [ 15%] Building C object CMakeFiles/bindarknet.dir/examples/lsd.c.o
      [ 16%] Building C object CMakeFiles/bindarknet.dir/src/matrix.c.o
      [ 16%] Building C object CMakeFiles/bindarknet.dir/src/maxpool_layer.c.o
      [ 17%] Building C object CMakeFiles/bindarknet.dir/src/network.c.o
      [ 17%] Building C object CMakeFiles/bindarknet.dir/examples/nightmare.c.o
      [ 18%] Building C object CMakeFiles/bindarknet.dir/src/normalization_layer.c.o
      [ 18%] Building C object CMakeFiles/bindarknet.dir/src/option_list.c.o
      [ 18%] Building C object CMakeFiles/bindarknet.dir/src/parser.c.o
      [ 19%] Building C object CMakeFiles/bindarknet.dir/src/region_layer.c.o
      [ 19%] Building C object CMakeFiles/bindarknet.dir/examples/regressor.c.o
      [ 20%] Building C object CMakeFiles/bindarknet.dir/src/reorg_layer.c.o
      [ 20%] Building C object CMakeFiles/bindarknet.dir/examples/rnn.c.o
      [ 21%] Building C object CMakeFiles/bindarknet.dir/src/rnn_layer.c.o
      [ 21%] Building C object CMakeFiles/bindarknet.dir/examples/rnn_vid.c.o
      [ 21%] Building C object CMakeFiles/bindarknet.dir/src/route_layer.c.o
      [ 22%] Building C object CMakeFiles/bindarknet.dir/src/shortcut_layer.c.o
      [ 22%] Building C object CMakeFiles/bindarknet.dir/src/softmax_layer.c.o
      [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/segmenter.c.o
      [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/super.c.o
      [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/swag.c.o
      [ 24%] Building C object CMakeFiles/bindarknet.dir/examples/tag.c.o
      [ 24%] Building C object CMakeFiles/bindarknet.dir/src/tree.c.o
      [ 25%] Building C object CMakeFiles/bindarknet.dir/src/utils.c.o
      [ 25%] Building C object CMakeFiles/bindarknet.dir/examples/voxel.c.o
      [ 26%] Building C object CMakeFiles/bindarknet.dir/examples/writing.c.o
      [ 26%] Building C object CMakeFiles/bindarknet.dir/examples/yolo.c.o
      [ 26%] Building C object CMakeFiles/bindarknet.dir/src/yolo_layer.c.o
      [ 27%] Building C object CMakeFiles/bindarknet.dir/src/upsample_layer.c.o
      [ 27%] Building C object CMakeFiles/bindarknet.dir/src/logistic_layer.c.o
      [ 28%] Building C object CMakeFiles/bindarknet.dir/src/l2norm_layer.c.o
      [ 28%] Building C object CMakeFiles/bindarknet.dir/src/activation_kernels.c.o
      [ 28%] Building C object CMakeFiles/bindarknet.dir/src/avgpool_layer_kernels.c.o
      [ 29%] Building C object CMakeFiles/bindarknet.dir/src/blas_kernels.c.o
      [ 29%] Building C object CMakeFiles/bindarknet.dir/src/col2im_kernels.c.o
      [ 30%] Building C object CMakeFiles/bindarknet.dir/src/convolutional_kernels.c.o
      [ 30%] Building C object CMakeFiles/bindarknet.dir/src/crop_layer_kernels.c.o
      [ 31%] Building C object CMakeFiles/bindarknet.dir/src/deconvolutional_kernels.c.o
      [ 31%] Building C object CMakeFiles/bindarknet.dir/src/dropout_layer_kernels.c.o
      [ 31%] Building C object CMakeFiles/bindarknet.dir/src/im2col_kernels.c.o
      [ 32%] Building C object CMakeFiles/bindarknet.dir/src/maxpool_layer_kernels.c.o
      [ 32%] Building C object CMakeFiles/bindarknet.dir/src/opencl.c.o
      [ 33%] Building C object CMakeFiles/bindarknet.dir/examples/darknet.c.o
      make[2]: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenCL.framework’, needed by `darknet’. Stop.
      make[1]: *** [CMakeFiles/bindarknet.dir/all] Error 2
      make: *** [all] Error 2
      cp: darknet: No such file or directory

      Thank for your help!

  3. Did you:

    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -license accept

    ? Thanks :-).

  4. hi … I tried to run “Make” and its giving me the following error.
    No rule to make target `obj/convolutional_kernels.o’,
    Not sure what to do … Cuda compiled correctly, OpenCV done correctly..
    Any insight.. ?

  5. Hi Sowa,
    Thanks for your great work.
    I try to modify your source to work on window version with AMD GPU (amd mobility radeon hd 5000 series).
    It seem to work but not much faster than yolov3 CPU version. I run it on the sample video, the performance just is 0.2 fps. In addition, It costs a lot of on-board RAM in comparison with CPU version.
    Could you please check my source if there is any issue, do you know how to locate on GPU RAM?
    Since I’m beginner in Computer version and window programming, I ‘m very appreciate if you can give me your help.
    You can check the source code as below,
    https://drive.google.com/drive/folders/1IxUp8cy48DQu0qp1hzq_MckvBZnvbaE9?usp=sharing
    and use darknet_voc_tiny_v3_video.cmd for runnning.
    Thank you,
    Best Regards,
    Tri Nguyen

  6. Hi,
    Im getting this when running darknet:
    opencl_load: could not link. error: CL_INVALID_LINKER_OPTIONS
    CL_PROGRAM_BUILD_LOG:
    Any ideas?

  7. Hi, piotr
    Can you please explain how to define memory size for the darknet?
    Compiled sucessfully but at run time,
    Loading weights from ../../yolov3.weights…Done!
    opencl fill_kernel error: CL_MEM_OBJECT_ALLOCATION_FAILURE
    Cheers and thanks,

    • Hi, I believe it is because YOLO3 model is much bigger than for example YOLO2 or YOLO1 and I think you may need more VRAM, or I did something wrong with the implementation. I had an opportunity to test it only on the: Sonnet AMD 570 4GB VRAM eGPU, Titan Xp 12 GB of VRAM, Titan RTX 24 GB VRAM… So maybe you have less memory than 4GB in your GPU? That is the hint only, but hope it makes sense. Thanks!

        • OK, so if we will be lucky that will be working… please go to the CFG file of YOLO3 and look for 2 values almost on the top of file equals 608, try to change the first to 416, then if still facing memory allocation issue to the 320. Also keep in mind that less size of the neural network because that is the meaning of those values, make your processing faster. Thanks!

          • Hi,
            Your suggestion works. Now it works.
            Have you ported the python examples?
            Thanks

  8. Hello I am following the instructions for macOS.
    After running make in the build folder I am getting this error:

    Scanning dependencies of target bindarknet
    [ 0%] Building C object CMakeFiles/bindarknet.dir/src/activation_layer.c.o
    [ 0%] Building C object CMakeFiles/bindarknet.dir/src/activations.c.o
    [ 1%] Building C object CMakeFiles/bindarknet.dir/examples/art.c.o
    [ 1%] Building C object CMakeFiles/bindarknet.dir/examples/attention.c.o
    [ 2%] Building C object CMakeFiles/bindarknet.dir/src/avgpool_layer.c.o
    [ 2%] Building C object CMakeFiles/bindarknet.dir/src/batchnorm_layer.c.o
    [ 2%] Building C object CMakeFiles/bindarknet.dir/src/blas.c.o
    [ 3%] Building C object CMakeFiles/bindarknet.dir/src/box.c.o
    [ 3%] Building C object CMakeFiles/bindarknet.dir/examples/captcha.c.o
    [ 4%] Building C object CMakeFiles/bindarknet.dir/examples/cifar.c.o
    [ 4%] Building C object CMakeFiles/bindarknet.dir/examples/classifier.c.o
    [ 5%] Building C object CMakeFiles/bindarknet.dir/examples/coco.c.o
    [ 5%] Building C object CMakeFiles/bindarknet.dir/src/col2im.c.o
    [ 5%] Building C object CMakeFiles/bindarknet.dir/src/compare.c.o
    [ 6%] Building C object CMakeFiles/bindarknet.dir/src/connected_layer.c.o
    [ 6%] Building C object CMakeFiles/bindarknet.dir/src/convolutional_layer.c.o
    [ 7%] Building C object CMakeFiles/bindarknet.dir/src/cost_layer.c.o
    [ 7%] Building C object CMakeFiles/bindarknet.dir/src/crnn_layer.c.o
    [ 7%] Building C object CMakeFiles/bindarknet.dir/src/crop_layer.c.o
    [ 8%] Building C object CMakeFiles/bindarknet.dir/src/data.c.o
    [ 8%] Building C object CMakeFiles/bindarknet.dir/src/deconvolutional_layer.c.o
    [ 9%] Building C object CMakeFiles/bindarknet.dir/src/demo.c.o
    [ 9%] Building C object CMakeFiles/bindarknet.dir/src/detection_layer.c.o
    [ 10%] Building C object CMakeFiles/bindarknet.dir/examples/detector.c.o
    [ 10%] Building C object CMakeFiles/bindarknet.dir/examples/dice.c.o
    [ 10%] Building C object CMakeFiles/bindarknet.dir/src/dropout_layer.c.o
    [ 11%] Building C object CMakeFiles/bindarknet.dir/src/gemm.c.o
    [ 11%] Building C object CMakeFiles/bindarknet.dir/examples/go.c.o
    [ 12%] Building C object CMakeFiles/bindarknet.dir/src/gru_layer.c.o
    [ 12%] Building C object CMakeFiles/bindarknet.dir/src/im2col.c.o
    [ 13%] Building C object CMakeFiles/bindarknet.dir/src/image.c.o
    [ 13%] Building C object CMakeFiles/bindarknet.dir/src/iseg_layer.c.o
    [ 13%] Building C object CMakeFiles/bindarknet.dir/examples/instance-segmenter.c.o
    [ 14%] Building C object CMakeFiles/bindarknet.dir/src/layer.c.o
    [ 14%] Building C object CMakeFiles/bindarknet.dir/src/list.c.o
    [ 15%] Building C object CMakeFiles/bindarknet.dir/src/local_layer.c.o
    [ 15%] Building C object CMakeFiles/bindarknet.dir/src/lstm_layer.c.o
    [ 15%] Building C object CMakeFiles/bindarknet.dir/examples/lsd.c.o
    [ 16%] Building C object CMakeFiles/bindarknet.dir/src/matrix.c.o
    [ 16%] Building C object CMakeFiles/bindarknet.dir/src/maxpool_layer.c.o
    [ 17%] Building C object CMakeFiles/bindarknet.dir/src/network.c.o
    [ 17%] Building C object CMakeFiles/bindarknet.dir/examples/nightmare.c.o
    [ 18%] Building C object CMakeFiles/bindarknet.dir/src/normalization_layer.c.o
    [ 18%] Building C object CMakeFiles/bindarknet.dir/src/option_list.c.o
    [ 18%] Building C object CMakeFiles/bindarknet.dir/src/parser.c.o
    [ 19%] Building C object CMakeFiles/bindarknet.dir/src/region_layer.c.o
    [ 19%] Building C object CMakeFiles/bindarknet.dir/examples/regressor.c.o
    [ 20%] Building C object CMakeFiles/bindarknet.dir/src/reorg_layer.c.o
    [ 20%] Building C object CMakeFiles/bindarknet.dir/examples/rnn.c.o
    [ 21%] Building C object CMakeFiles/bindarknet.dir/src/rnn_layer.c.o
    [ 21%] Building C object CMakeFiles/bindarknet.dir/examples/rnn_vid.c.o
    [ 21%] Building C object CMakeFiles/bindarknet.dir/src/route_layer.c.o
    [ 22%] Building C object CMakeFiles/bindarknet.dir/src/shortcut_layer.c.o
    [ 22%] Building C object CMakeFiles/bindarknet.dir/src/softmax_layer.c.o
    [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/segmenter.c.o
    [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/super.c.o
    [ 23%] Building C object CMakeFiles/bindarknet.dir/examples/swag.c.o
    [ 24%] Building C object CMakeFiles/bindarknet.dir/examples/tag.c.o
    [ 24%] Building C object CMakeFiles/bindarknet.dir/src/tree.c.o
    [ 25%] Building C object CMakeFiles/bindarknet.dir/src/utils.c.o
    [ 25%] Building C object CMakeFiles/bindarknet.dir/examples/voxel.c.o
    [ 26%] Building C object CMakeFiles/bindarknet.dir/examples/writing.c.o
    [ 26%] Building C object CMakeFiles/bindarknet.dir/examples/yolo.c.o
    [ 26%] Building C object CMakeFiles/bindarknet.dir/src/yolo_layer.c.o
    [ 27%] Building C object CMakeFiles/bindarknet.dir/src/upsample_layer.c.o
    [ 27%] Building C object CMakeFiles/bindarknet.dir/src/logistic_layer.c.o
    [ 28%] Building C object CMakeFiles/bindarknet.dir/src/l2norm_layer.c.o
    [ 28%] Building C object CMakeFiles/bindarknet.dir/src/activation_kernels.c.o
    [ 28%] Building C object CMakeFiles/bindarknet.dir/src/avgpool_layer_kernels.c.o
    [ 29%] Building C object CMakeFiles/bindarknet.dir/src/blas_kernels.c.o
    [ 29%] Building C object CMakeFiles/bindarknet.dir/src/col2im_kernels.c.o
    [ 30%] Building C object CMakeFiles/bindarknet.dir/src/convolutional_kernels.c.o
    [ 30%] Building C object CMakeFiles/bindarknet.dir/src/crop_layer_kernels.c.o
    [ 31%] Building C object CMakeFiles/bindarknet.dir/src/deconvolutional_kernels.c.o
    [ 31%] Building C object CMakeFiles/bindarknet.dir/src/dropout_layer_kernels.c.o
    [ 31%] Building C object CMakeFiles/bindarknet.dir/src/im2col_kernels.c.o
    [ 32%] Building C object CMakeFiles/bindarknet.dir/src/maxpool_layer_kernels.c.o
    [ 32%] Building C object CMakeFiles/bindarknet.dir/src/opencl.c.o
    [ 33%] Building C object CMakeFiles/bindarknet.dir/examples/darknet.c.o
    make[2]: *** No rule to make target `/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenCL.framework’, needed by `darknet’. Stop.
    make[1]: *** [CMakeFiles/bindarknet.dir/all] Error 2
    make: *** [all] Error 2

    How can I solve this?

    • Hello, please take a look at the top of the post I updated a post and added the Ubuntu 20.04 steps to install… please test and let me know. Enjoy!

      • Thank you! I followed evertyhing but I am getting this error:

        terminate called after throwing an instance of ‘cv::Exception’
        what(): OpenCV(3.4.12) /home/user/opencv-3.4.12/modules/core/src/matrix_wrap.cpp:771: error: (-215:Assertion failed) (flags & FIXED_TYPE) != 0 in function ‘type’

        Aborted (core dumped)

        Any ideas?

    • Yes, you need to take YOLO4 CFGs and change names of layer from [yolo] to [yolo4] in those files once I need to have YOLO3 model also working… In this way I have backward capability in place. on the https://github.com/sowson/darknet in cfg folder you have already prepared CFGs for YOLO4 :-). And Issue with title YOLO4 already closed, has discussion and results inside… Enjoy Jin!

    • Also on the ubuntu20 install, this line accidentally had the double dashes — turned into a long m-dash before the opencl argument:
      ./amdgpu-pro-install -y –opencl=pal,legacy
      which results in this error:
      E: Invalid operation –opencl=pal,legacy
      ERROR: Unable to install pin package.

      To fix it, use this command:
      ./amdgpu-pro-install -y --opencl=pal,legacy

  9. Hi,
    In new PC with NVIDIA on Ubuntu 20.04, try to compile but failed.
    Can you help it?

    $ cat Makefile
    GPU=1
    GPU_FAST=1
    GPU_MULTI=0
    GPU_SAFE=1
    OPENCV=1
    OPENMP=1
    # Choose only one (works if GPU=1): NVIDIA or AMD or ARM (for VC4CL or MaliGPU)
    NVIDIA=1
    AMD=0
    ARM=0
    BENCHMARK=0
    LOSS_ONLY=0
    DEBUG=0

    user@W1131507i:~/github_darknet/darknet$ make
    gcc -Wall -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-result -Wno-deprecated-declarations -Wno-return-type-c-linkage -Wno-unused-function -Wfatal-errors -fPIC -openmp -O2 -DOPENCV -DGPU -DOPENCL -I/usr/include/ -I/usr/local/cuda/include/ -DGPU_SAFE -DGPU_FAST -shared obj/gemm.o obj/utils.o obj/opencl.o obj/deconvolutional_layer.o obj/convolutional_layer.o obj/list.o obj/image.o obj/iseg_layer.o obj/activations.o obj/im2col.o obj/col2im.o obj/blas.o obj/crop_layer.o obj/dropout_layer.o obj/maxpool_layer.o obj/softmax_layer.o obj/data.o obj/matrix.o obj/network.o obj/connected_layer.o obj/cost_layer.o obj/parser.o obj/option_list.o obj/detection_layer.o obj/route_layer.o obj/box.o obj/normalization_layer.o obj/avgpool_layer.o obj/layer.o obj/local_layer.o obj/shortcut_layer.o obj/activation_layer.o obj/rnn_layer.o obj/gru_layer.o obj/crnn_layer.o obj/demo.o obj/batchnorm_layer.o obj/region_layer.o obj/reorg_layer.o obj/tree.o obj/lstm_layer.o obj/yolo_layer.o obj/yolo4_layer.o obj/gaussian_yolo4_layer.o obj/upsample_layer.o obj/logistic_layer.o obj/l2norm_layer.o obj/image_opencv.o obj/convolutional_kernels.o obj/deconvolutional_kernels.o obj/activation_kernels.o obj/im2col_kernels.o obj/col2im_kernels.o obj/blas_kernels.o obj/crop_layer_kernels.o obj/dropout_layer_kernels.o obj/maxpool_layer_kernels.o obj/avgpool_layer_kernels.o -o libdarknet.so -lm -lz -lpthread `pkg-config --libs opencv` -L/usr/local/cuda/lib64 -lOpenCL -L/usr/lib64 -lclBLAS -L/usr/lib64 -lstdc++
    /usr/bin/ld: cannot find -lopencv_contrib
    /usr/bin/ld: cannot find -lopencv_legacy
    /usr/bin/ld: cannot find -l-L/usr/local/cuda/lib64
    collect2: error: ld returned 1 exit status
    make: *** [Makefile:143: libdarknet.so] Error 1

  10. Hello,

    I get the error below:


    — The C compiler identification is AppleClang 9.1.0.9020039
    — The CXX compiler identification is AppleClang 9.1.0.9020039
    — Check for working C compiler: /usr/bin/gcc
    — Check for working C compiler: /usr/bin/gcc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info — done
    — Detecting C compile features
    — Detecting C compile features — done
    — Check for working CXX compiler: /usr/bin/g++
    — Check for working CXX compiler: /usr/bin/g++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info — done
    — Detecting CXX compile features
    — Detecting CXX compile features — done
    — Looking for CL_VERSION_2_2
    — Looking for CL_VERSION_2_2 — not found
    — Looking for CL_VERSION_2_1
    — Looking for CL_VERSION_2_1 — not found
    — Looking for CL_VERSION_2_0
    — Looking for CL_VERSION_2_0 — not found
    — Looking for CL_VERSION_1_2
    — Looking for CL_VERSION_1_2 — found
    — Found OpenCL: /System/Library/Frameworks/OpenCL.framework (found version “1.2”)
    — Configuring done
    — Generating done
    — Build files have been written to: /Users/ricardoramirez/workspace/yolo/sowson/darknet/build
    — Configuring done
    — Generating done
    — Build files have been written to: /Users/ricardoramirez/workspace/yolo/sowson/darknet/build
    cp: build/darknet: No such file or directory

    [ 99%] Building CXX object CMakeFiles/darknet_l.dir/src/image_opencv.cpp.o
    [100%] Linking CXX static library libdarknet_s.a
    [100%] Built target darknet_s
    [100%] Linking CXX executable darknet
    [100%] Linking CXX shared library libdarknet_l.so
    [100%] Built target darknet_l
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `open_video_stream’:
    /home/user/darknet/src/image_opencv.cpp:164: undefined reference to `cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `show_image_frame_cv’:
    /home/user/darknet/src/image_opencv.cpp:182: undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `make_window_cv’:
    /home/user/darknet/src/image_opencv.cpp:190: undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’
    /usr/local/bin/ld: /home/user/darknet/src/image_opencv.cpp:192: undefined reference to `cv::setWindowProperty(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, double)’
    /usr/local/bin/ld: /home/user/darknet/src/image_opencv.cpp:194: undefined reference to `cv::resizeWindow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, int)’
    /usr/local/bin/ld: /home/user/darknet/src/image_opencv.cpp:195: undefined reference to `cv::moveWindow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, int)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `cv_capture_from_file’:
    /home/user/darknet/src/image_opencv.cpp:257: undefined reference to `cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `is_invalid_file_to_imread_cv’:
    /home/user/darknet/src/image_opencv.cpp:371: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `load_image_cv’:
    /home/user/darknet/src/image_opencv.cpp:396: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `save_image_jpg_cv’:
    /home/user/darknet/src/image_opencv.cpp:463: undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/src/image_opencv.cpp.o: in function `mark_image_and_save_cv’:
    /home/user/darknet/src/image_opencv.cpp:248: undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)’
    /usr/local/bin/ld: CMakeFiles/darknet.dir/examples/detector.c.o: in function `test_ddetector’:
    /home/user/darknet/examples/detector.c:756: undefined reference to `empty’
    collect2: error: ld returned 1 exit status
    — darknet —
    *** [darknet] Error code 1

    make[2]: stopped in /usr/home/user/darknet/build
    1 error

    make[2]: stopped in /usr/home/user/darknet/build
    — CMakeFiles/darknet.dir/all —
    *** [CMakeFiles/darknet.dir/all] Error code 2

    make[1]: stopped in /usr/home/user/darknet/build
    1 error

    make[1]: stopped in /usr/home/user/darknet/build
    *** [all] Error code 2

    make: stopped in /usr/home/user/darknet/build
    1 error

    make: stopped in /usr/home/user/darknet/build

  11. Hello Sowa, thank you for replying.

    I am using FreeBSD 13.1.

    I was able to let the program to reach at 100% compilation but during at the end stage of linking during compilation, I get errors related to OpenCV undefined references.

    I see that you have replied to your GitHub. I will reply there:
    https://github.com/sowson/darknet/issues/79

    Thank You.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.