A warning I saw for the first time in Opencv

When I run my Python code in Visual Studio, this warning message appears and continues to work, but when I convert my code to exe, it closes instantly without giving any error.

[ WARN:0@34.474] global D:\a\opencv-python\opencv-python\opencv\modules\core\src\ocl.cpp (1020) cv::ocl::OpenCLExecutionContext::Impl::getInitializedExecutionContext OpenCL: Can't initialize OpenCL context/device/queue: unknown C++ exception

What you saw at the beginning [WARN:0@34.474 ] every time I run the program, the part consisting of numbers changes.

Can someone tell me exactly what I should do? My video card is not good. and I don’t use C++ in my code,
When I run it in debug mode, there are no problems when I run it in normal mode, there are no problems, only a warning message comes, but when it to exe, it closes instantly without giving any errors.

it’s weird, that it cannot initialize an opencl context, this should be well supported (esp. on windows)

opencv is written in c++. the python bindings are only shallow wrappers.

well known problem. those pytoexe things swallow up any useful error msg. seriously, rather avoid it.

maybe try to disable OCL usage: setUseOpenCL

Am I going to add this to my own code or somewhere else?

add it, like, the 1st line in main()

oh my, you’re supposed to write:


(and please, NEVER post screenshots of code anywhere)

“closes instantly”? did you double-click on a command line program? run it from a terminal/console…

I deleted it and was going to switch to tensorflow because of this error, thanks you saved me now it works.