Thursday, February 1, 2018

Building Darknet

First install cuda

https://gist.github.com/derek-pappas/c5a73efe4b5748a034c6a0a9b76b67c7

Then install Darknet
The install script does not work for everyone. Try this if it fails.


cp -r $HOME/DockerDarknet /opt
chown $USER:$USER -R DockerDarknet/

cd /opt/DockerDarknet/

git pull

make


https://github.com/cracker0dks/DockerDarknet/blob/master/README.md 

Forked from:

https://github.com/Guanghan/darknet

Debugging

: /opt/DockerDarknet
$ make
nvcc --gpu-architecture=compute_20 --gpu-code=compute_20  -DGPU -I/usr/local/cuda/include/ --compiler-options "-Wall -Wfatal-errors  -Ofast -DGPU" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o
nvcc fatal   : Value 'compute_20' is not defined for option 'gpu-architecture'
Makefile:54: recipe for target 'obj/convolutional_kernels.o' failed
make: *** [obj/convolutional_kernels.o] Error 1


Options for steering GPU code generation.
=========================================

--gpu-architecture <arch>                  (-arch)                          
        Specify the name of the class of NVIDIA 'virtual' GPU architecture for which
        the CUDA input files must be compiled.
        With the exception as described for the shorthand below, the architecture
        specified with this option must be a 'virtual' architecture (such as compute_50).
        Normally, this option alone does not trigger assembly of the generated PTX
        for a 'real' architecture (that is the role of nvcc option '--gpu-code',
        see below); rather, its purpose is to control preprocessing and compilation
        of the input to PTX.
        For convenience, in case of simple nvcc compilations, the following shorthand
        is supported.  If no value for option '--gpu-code' is specified, then the
        value of this option defaults to the value of '--gpu-architecture'.  In this
        situation, as only exception to the description above, the value specified
        for '--gpu-architecture' may be a 'real' architecture (such as a sm_50),
        in which case nvcc uses the specified 'real' architecture and its closest
        'virtual' architecture as effective architecture values.  For example, 'nvcc
        --gpu-architecture=sm_50' is equivalent to 'nvcc --gpu-architecture=compute_50
        --gpu-code=sm_50,compute_50'.
        Allowed values for this option:  'compute_30','compute_32','compute_35',
        'compute_37','compute_50','compute_52','compute_53','compute_60','compute_61',
        'compute_62','compute_70','compute_72','sm_30','sm_32','sm_35','sm_37','sm_50',
        'sm_52','sm_53','sm_60','sm_61','sm_62','sm_70','sm_72'.


/opt/DockerDarknet
$ grep -r compute_20 *
Makefile:ARCH= --gpu-architecture=compute_20 --gpu-code=compute_20

How to use the standard Darknet


docker exec -it darknet /bin/bash

Now you can use Darknet yolo with the standard documentation:

http://pjreddie.com/darknet/yolo/

cd training

wget https://pjreddie.com/media/files/yolo.weights

./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg