Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change OpenCL device.

Hello, I'm an image process software developer and using OpenCV3.2.0.

I'm also using OpenCL, and confronting with a problem as shown below.


※ PC Environment

  • CPU : Intel(R) Core(TM) i5-6300HQ
  • iGPU : Intel(R) HD Graphics 530
  • dGPU : NVIDIA Quadro M1000M

Qestion

If my knowledge is correct, I have 2 platforms(Intel, NVIDIA), and 3 devices(CPU, iGPU, dGPU).

And I want to use dGPU when an application running on the CPU tries to perform image processing.

But both platforms are different, can't I do it?

Thanks in advance.


What I tried

try 1

the code runing on the CPU

cv::ocl::Context context;
context.create(cv::ocl::Device::TYPE_ALL); … ①
cv::ocl::Device device;

std::string deviceName;

for(int i = 0; i < context.ndevices(); i++) {
    device = context.device(i);
    deviceName = device.name();
}

"deviceName" is always "Intel(R) HD Graphics 530".

I changed ① to TYPE_GPU, TYPE_DGPU, there was no change.


try 2

std::vector<cv::ocl::PlatformInfo> platforms;
cv::ocl::getPlatfomsInfo(platforms);
const cv::ocl::PlatformInfo* platform;

std::string name = platform->name();

for(int i = 0; i < platforms.size(); i++) {
    platform = &platforms[i];
    platform->getDevice(device, 0);
    deviceName = device.name();
}

"deviceName" are "Intel(R) HD Graphics 530", "Quadro M1000M".

It seems dGPU is recognized, but I don't know how to fix it to GPGPU device.


try 3

I changed OPENCV_OPENCL_DEVICE environment variable to "NVIDIA:DGPU:1000", there was no change.