Darknet integration problems and how to solve them

Source: Internet
Author: User

When the darknet is integrated into the project, there are some problems, the following record the workaround:

Integration steps:

First, when the YOLO is compiled, you need to open three switches:

#define GPU
#define CUDNN
#define OPENCV

Put the compiled libdarknet.so and darknet.h into the corresponding project folder respectively;

Add the corresponding Lib path and include path in CMakeLists.txt;

Add the appropriate CPP and HPP as well as the main function test code, and modify the corresponding CMakeLists.txt;

Compile

The problems encountered and how to resolve them are as follows:

Problem: Functions such as load_network are not defined and cannot be found

Cause: YOLO is a pure C framework, the project is C + +, so the function to be called needs to add extern "C" {}

Workaround: Include all function definitions in darknet.h with extern "C" {}

Problem: List ambigous;

Reason: in C + + standard library has list this container, but in darknet.h also defined the same name structure body;

WORKAROUND: Apply the global using namespace Std to the project, remove it and use std:

Question: Caffe::caffe::set_mode (CAFFE::CAFFE::GPU), error here, specifically forget what is wrong, in short, is related to the # define GPU in Darknet.h

Workaround:

#undef GPU
Caffe::caffe::set_mode (CAFFE::CAFFE::GPU);
#define GPU

Problem: No. 0 Graphics card running the project when normal, instead of the 1th graphics card times wrong: CUDA error:an Illegal memory access was encountered./src/cuda.c:36:check_error:assertion ' 0 ' failed.

Reason: Search for the relevant solution on the net, generally is the computation ability that place changes after recompile YOLO, but with me is not the same situation, I was in call Setdeviceid when the mistake;

WORKAROUND: You should call Cuda_set_device (GPU_ID) before calling Load_network (_cfgfile, _weightfile, 0);

At present, the YOLO is the above problems;

There are some other soft links can not find the problem, and later found to be connected to the system path to go, rather than connect to the same folder under the library, do not know how to cause, only delete the re-link.

Darknet integration problems and how to solve them

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.