最近、OpenCL 1.2 のみの GPU カードから OpenCL 2.0 (R9 390) の GPU カードにアップグレードしました。それを OpenCV で使い始めるために、私はいくつかの基本的な呼び出しを作成して、各ライブラリーが私が持っていると考えていたハードウェアを判別しました。
cout << "Equipment according to OpenCV:" << endl;
//Setup OpenCV first
cv::ocl::setUseOpenCL(true);
//OpenCV: Platform Info
std::vector<cv::ocl::PlatformInfo> platforms;
cv::ocl::getPlatfomsInfo(platforms);
//OpenCV Platforms
for (size_t i = 0; i < platforms.size(); i++)
{
const cv::ocl::PlatformInfo* platform = &platforms[i];
//Platform Name
std::cout << "Platform Name: " << platform->name().c_str() << "\n";
//Access known device
cv::ocl::Device current_device;
for (int j = 0; j < platform->deviceNumber(); j++)
{
//Access Device
platform->getDevice(current_device, j);
std::cout << "Device Name: " << current_device.name().c_str() << "\n";
}
}
cv::ocl::Device(current_device); // Required?
cout << cvContext.ndevices() << " GPU devices are detected." << endl;
for (int i = 0; i < cvContext.ndevices(); i++)
{
cv::ocl::Device device = cvContext.device(i);
cout << "name: " << device.name() << endl;
cout << "available: " << device.available() << endl;
cout << "imageSupport: " << device.imageSupport() << endl;
cout << "OpenCL_C_Version: " << device.OpenCL_C_Version() << endl;
cout << "Use OpenCL: " << cv::ocl::useOpenCL() << endl;
cout << endl;
}
cv::ocl::Device(cvContext.device(0)); //Here is where you change which GPU to use (e.g. 0 or 1)
// Setup OpenCL
cout << "Equipment according to OpenCL:" << endl;
vector<cl::Platform> clPlatforms;
vector<cl::Device> clPlatformDevices, clAllDevices;//, clCTXdevices;
string clPlatform_name, clDevice_name;
cl_uint i;
cl::Platform::get(&clPlatforms);
for(i=0; i<clPlatforms.size();i++)
{
clPlatform_name = clPlatforms[i].getInfo<CL_PLATFORM_NAME>();
cout<< "Platform: " <<clPlatform_name.c_str()<<endl;
clPlatforms[i].getDevices(CL_DEVICE_TYPE_ALL, &clPlatformDevices);
// Create context and access device names
clContext = cl::Context(clPlatformDevices);
clCTXdevices = clContext.getInfo<CL_CONTEXT_DEVICES>();
for(i=0; i<clCTXdevices.size(); i++) {
clDevice_name = clCTXdevices[i].getInfo<CL_DEVICE_NAME>();
cout << "Device: " << clDevice_name.c_str() << endl;
}
}
cout << "OpenCL Version: "<<clPlatforms[0].getInfo<CL_PLATFORM_VERSION>().c_str() <<endl;
cout << "Vendor: "<<clPlatforms[0].getInfo<CL_PLATFORM_VENDOR>().c_str() <<endl;
cout << "Extensions: "<<clPlatforms[0].getInfo<CL_PLATFORM_EXTENSIONS>().c_str() <<endl;
そして出力:
Equipment according to OpenCV:
Platform Name: AMD Accelerated Parallel Processing
Device Name: Hawaii
Device Name: Intel(R) Core(TM)2 Quad CPU Q9450 @ 2.66GHz
1 GPU devices are detected.
name: Hawaii
available: 1
imageSupport: 1
OpenCL_C_Version: OpenCL C 1.2
Use OpenCL: 1
Equipment according to OpenCL:
Platform: AMD Accelerated Parallel Processing
Device: Hawaii
Device: Intel(R) Core(TM)2 Quad CPU Q9450 @ 2.66GHz
OpenCL Version: OpenCL 2.0 AMD-APP (1729.3)
Vendor: Advanced Micro Devices, Inc.
Extensions: cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
したがって、OpenCV は私が OpenCL 1.2 を持っていると考えていますが、OpenCL は少し賢く、2.0 を返します...同じバージョンの OpenCL を返さない理由はありますか? 利用可能な新しいバージョンの OpenCL があることを認識できるように、OpenCV を再コンパイルする必要があるかどうか疑問に思っていますか? OpenCV 3.0 は OpenCL 1.2 呼び出しの使用に制限されていますか? ありがとう!