Opencv: cv::ocl::setUseOpenCL(false) does not really stop using GPU

Created on 18 Jan 2017  路  1Comment  路  Source: opencv/opencv

System information (version)
  • OpenCV => 3.2
  • Operating System / Platform => Windows 10
  • Compiler => VS 2013
Detailed description

I set cv::ocl::setUseOpenCL(false); and verified using useOpenCL(). But my code is still using GPU when I use UMat. How can I stop using GPU? Temporarily I am using a workaround that uses Mat instead of UMat. UMat should not use GPU when ocl is not used.

Steps to reproduce

Just use UMat in your code. Do some computation. Set cv::ocl::setUseOpenCL(false).
I used GPU-Z to verify GPU load/usage.

bug core ocl t-api

Most helpful comment

I checked this with GPU-Z using Visual Studio (32bit), Windows 7 and OpenCV 3.2 for build and it does not use GPU when I set ocl::setUseOpenCL(false). Same for Visual Studio 2013 (32bit), Windows 7 and OpenCV 3.1.

But three things you should consider:

  1. When running functions the first time OpenCL code will be initialized even if cv::Mat are used. (cv::ocl::setUseOpenCL(true) must be true).
  2. If I switch from ocl::setUseOpenCL(true) to ocl::setUseOpenCL(false) I have to release UMats first otherwise I get memory leaks.
  3. When running functions in different threads ocl::setUseOpenCL becomes true for every new thread and it has to be disabled explicit for every thread.

>All comments

I checked this with GPU-Z using Visual Studio (32bit), Windows 7 and OpenCV 3.2 for build and it does not use GPU when I set ocl::setUseOpenCL(false). Same for Visual Studio 2013 (32bit), Windows 7 and OpenCV 3.1.

But three things you should consider:

  1. When running functions the first time OpenCL code will be initialized even if cv::Mat are used. (cv::ocl::setUseOpenCL(true) must be true).
  2. If I switch from ocl::setUseOpenCL(true) to ocl::setUseOpenCL(false) I have to release UMats first otherwise I get memory leaks.
  3. When running functions in different threads ocl::setUseOpenCL becomes true for every new thread and it has to be disabled explicit for every thread.
Was this page helpful?
0 / 5 - 0 ratings