Ask Your Question

Revision history [back]

Issue is resolved. I don't know what I did but AMD is working now.

Current settings (On Windows):

  1. Environment Variable:

    Name: OPENCV_OPENCL_DEVICE
    
    Value: AMD:GPU:Capeverde
    
  2. Using setUseOpenCL(bool foo) present in ocl.hpp to select whether to use GPU or CPU.

Most likely problem: In my actual code, I wasn't doing any computation but when I wrote a simple code for subtraction of two matrices, AMD started working.

Code:

#include <opencv2/core/ocl.hpp>
#include <opencv2/opencv.hpp>

int main() {
    cv::UMat mat1 = cv::UMat::ones(10, 10, CV_32F);
    cv::UMat mat2 = cv::UMat::zeros(10, 10, CV_32F);
    cv::UMat output = cv::UMat(10, 10, CV_32F);
    cv::subtract(mat1, mat2, output);
    std::cout << output << "\n";
    std::getchar();
}