Giter VIP home page Giter VIP logo

opencv-dnn-cuda-test's Introduction

opencv-dnn-cuda-test

Sample code of testing functions of OpenCV with CUDA-enabled DNN modules.

Setting up

$ cd yolos
$ wget https://pjreddie.com/media/files/yolov3.weights
$ cd ..

Then go to either Python or C++ part to validate the installation of OpenCV with CUDA-enabled DNN modules.

Special Thanks

Thanks for YashasSamaga providing a quick dirty way to measure FPS. You can visit his work about this:

As C++ part, I adapted some lines from the following (written by YashasSamaga):

Also, he provides the way to compile OpenCV version 4.x without errors:

opencv-dnn-cuda-test's People

Contributors

cuda-chen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

opencv-dnn-cuda-test's Issues

Missing yolov3.weights file

Line 9 of main.py has:

net = cv.dnn.readNet(model="../yolos/yolov3.weights", config="../yolos/yolov3.cfg")

But the file yolov3.weights is not anywhere in the repository.

Thus, executing the python test fails:

(opencv_cuda) jsalvo@rig01:~/projects/opencv-dnn-cuda-test/python_code$ python main.py
Traceback (most recent call last):
File "main.py", line 9, in <module>
net = cv.dnn.readNet(model="../yolos/yolov3.weights", config="../yolos/yolov3.cfg")
cv2.error: OpenCV(4.4.0) /home/jsalvo/projects/opencv/modules/dnn/src/darknet/darknet_importer.cpp:214: error: (-212:Parsing error) Failed to parse NetParameter file: ../yolos/yolov3.weights in function 'readNetFromDarknet'

Failing to build cpp_code/main.cpp

Hi there,

Thanks for this repo to test out CUDA with DNN. I have built OpenCV 4.4.0 on Ubuntu 20.04 LTS and the Python verification works.

However, I am unable to build main.cpp under cpp_code directory. I am not a C++ programmer, but I would like to ensure that the all tests works fine. When I build as per README.md:

g++ -o opencv_dnn_cuda_test_cpp main.cpp -I/usr/local/include/opencv4 -lopencv_core -lopencv_dnn -lopencv_highgui -lopencv_imgcodecs

.. I get lots of linking errors, like complaining about OpenCL:

	usr/bin/ld: /usr/local/lib/libopencv_core.a(opencl_core.cpp.o): in function `opencl_check_fn(int)':
	opencl_core.cpp:(.text._ZL15opencl_check_fni+0x3f): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x11a): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x131): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x19d): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x1b4): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x1ea): undefined reference to `dlclose'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL15opencl_check_fni+0x227): undefined reference to `dlclose'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(opencl_core.cpp.o): in function `OPENCL_FN_clUnloadCompiler_switch_fn()':
	opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x32): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x10b): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x122): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x18e): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x1a5): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x1db): undefined reference to `dlclose'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clUnloadCompiler_switch_fnv+0x218): undefined reference to `dlclose'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(opencl_core.cpp.o): in function `OPENCL_FN_clReleaseSampler_switch_fn(_cl_sampler*)':
	opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x37): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x113): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x12a): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x196): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x1ad): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x1e3): undefined reference to `dlclose'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL36OPENCL_FN_clReleaseSampler_switch_fnP11_cl_sampler+0x220): undefined reference to `dlclose'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(opencl_core.cpp.o): in function `OPENCL_FN_clUnloadPlatformCompiler_switch_fn(_cl_platform_id*)':
	opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x37): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x113): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x12a): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x196): undefined reference to `dlopen'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x1ad): undefined reference to `dlsym'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x1e3): undefined reference to `dlclose'
	/usr/bin/ld: opencl_core.cpp:(.text._ZL44OPENCL_FN_clUnloadPlatformCompiler_switch_fnP15_cl_platform_id+0x220): undefined reference to `dlclose'

.. to:

	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::TlsAbstraction::~TlsAbstraction()':
	system.cpp:(.text._ZN2cv7details14TlsAbstractionD2Ev+0x8): undefined reference to `pthread_key_delete'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::TlsAbstraction::getData_() const':
	system.cpp:(.text._ZNK2cv7details14TlsAbstraction8getData_Ev+0x7): undefined reference to `pthread_getspecific'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::ipp::IPPInitSingleton::IPPInitSingleton()':
	system.cpp:(.text._ZN2cv3ipp16IPPInitSingletonC2Ev[_ZN2cv3ipp16IPPInitSingletonC5Ev]+0x65): undefined reference to `ippicvGetCpuFeatures'
	/usr/bin/ld: system.cpp:(.text._ZN2cv3ipp16IPPInitSingletonC2Ev[_ZN2cv3ipp16IPPInitSingletonC5Ev]+0x3fc): undefined reference to `ippicvInit'
	/usr/bin/ld: system.cpp:(.text._ZN2cv3ipp16IPPInitSingletonC2Ev[_ZN2cv3ipp16IPPInitSingletonC5Ev]+0x401): undefined reference to `ippicvGetEnabledCpuFeatures'
	/usr/bin/ld: system.cpp:(.text._ZN2cv3ipp16IPPInitSingletonC2Ev[_ZN2cv3ipp16IPPInitSingletonC5Ev]+0x448): undefined reference to `ippicviGetLibVersion'
	/usr/bin/ld: system.cpp:(.text._ZN2cv3ipp16IPPInitSingletonC2Ev[_ZN2cv3ipp16IPPInitSingletonC5Ev]+0x531): undefined reference to `ippicvSetCpuFeatures'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::TlsAbstraction::TlsAbstraction()':
	system.cpp:(.text._ZN2cv7details14TlsAbstractionC2Ev+0x22): undefined reference to `pthread_key_create'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::TlsAbstraction::setData_(void*)':
	system.cpp:(.text._ZN2cv7details14TlsAbstraction8setData_EPv+0x1c): undefined reference to `pthread_setspecific'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::getTlsAbstraction()':
	system.cpp:(.text._ZN2cv7detailsL17getTlsAbstractionEv+0xaf): undefined reference to `pthread_key_create'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::details::opencv_tls_destructor(void*)':
	system.cpp:(.text._ZN2cv7detailsL21opencv_tls_destructorEPv+0x1c4): undefined reference to `pthread_getspecific'
	/usr/bin/ld: system.cpp:(.text._ZN2cv7detailsL21opencv_tls_destructorEPv+0x1eb): undefined reference to `pthread_setspecific'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::TLSData<cv::(anonymous namespace)::ThreadID>::createDataInstance() const':
	system.cpp:(.text._ZNK2cv7TLSDataINS_12_GLOBAL__N_18ThreadIDEE18createDataInstanceEv+0x50): undefined reference to `__itt_thread_set_name_ptr__3_0'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::TLSDataContainer::getData() const':
	system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv+0x58): undefined reference to `pthread_getspecific'
	/usr/bin/ld: system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv+0xe3): undefined reference to `pthread_getspecific'
	/usr/bin/ld: system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv+0x1a4): undefined reference to `pthread_setspecific'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(system.cpp.o): in function `cv::TLSDataContainer::getData() const [clone .constprop.0]':
	system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv.constprop.0+0x54): undefined reference to `pthread_getspecific'
	/usr/bin/ld: system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv.constprop.0+0xdb): undefined reference to `pthread_getspecific'
	/usr/bin/ld: system.cpp:(.text._ZNK2cv16TLSDataContainer7getDataEv.constprop.0+0x194): undefined reference to `pthread_setspecific'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(trace.cpp.o): in function `cv::utils::trace::details::isITTEnabled()':
	trace.cpp:(.text._ZN2cv5utils5trace7detailsL12isITTEnabledEv+0x88): undefined reference to `__itt_api_version_ptr__3_0'
	/usr/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7detailsL12isITTEnabledEv+0x9f): undefined reference to `__itt_domain_create_ptr__3_0'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(trace.cpp.o): in function `cv::utils::trace::details::Region::LocationExtraData::LocationExtraData(cv::utils::trace::details::Region::LocationStaticStorage const&)':
	trace.cpp:(.text._ZN2cv5utils5trace7details6Region17LocationExtraDataC2ERKNS3_21LocationStaticStorageE+0x3b): undefined reference to `__itt_string_handle_create_ptr__3_0'
	/usr/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details6Region17LocationExtraDataC2ERKNS3_21LocationStaticStorageE+0x118): undefined reference to `__itt_api_version_ptr__3_0'
	/usr/bin/ld: trace.cpp:(.text._ZN2cv5utils5trace7details6Region17LocationExtraDataC2ERKNS3_21LocationStaticStorageE+0x130): undefined reference to `__itt_domain_create_ptr__3_0'
	/usr/bin/ld: /usr/local/lib/libopencv_core.a(trace.cpp.o): in function `cv::utils::trace::details::Region::Impl::~Impl()':

Can you suggest where I should start looking at what the problem is ?

how to use the maximum of GPU Capacity

Hello ,about utilization of GPU how can be improve it :
like you see when i tap command line watch nvidia-smi to wach utilization of GPU: i found that script python use just 985 MIb of GPU, my script need more resources of GPU . if you have a command line or lines python to accelerate it .
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.