Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCL context does not get created

Don't really know how to word it, but long story short, I have built OpenCV from source cv::getBuildInformation() says that OpenCL is indeed installed. I have an GTX 1050, CV is also compiled with CUDA. Ubuntu 16.04. I have the same code on my work computer (has i7-4610m and AMD 8960m) CV is built from source with OpenCL and it gives me the info

Code used:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>


int main(int argc, char **argv)
{
  cv::ocl::setUseOpenCL(true);
  cv::setUseOptimized(true);
  std::cout << cv::getBuildInformation() << std::endl;
  if (cv::useOptimized())
  {
     std::cout << "using optimized" << std::endl;
  }

  if (!cv::ocl::haveOpenCL())
  {
     std::cout << "no opencl" << std::endl;
  }

  cv::ocl::Context context;
  if (!context.create(cv::ocl::Device::TYPE_GPU)) //I've tried all of the TYPE_ they all do the same thing
  {
     std::cout << "failed to create" << std::endl;
  }
  std::cout << context.ndevices() << " GPU devices are detected." << std::endl;
  std::cout << "++++++++++++++" << std::endl;
  for (size_t i = 0; i < context.ndevices(); i++)
  {
     cv::ocl::Device device = context.device(i);
     std::cout << "name: " << device.name() << std::endl;
     std::cout << "available: " << device.available() << std::endl;
     std::cout << "img support: " << device.imageSupport() << std::endl;
     std::cout << "cl v: " << device.OpenCL_C_Version() << std::endl;
  }
  std::cout << "++++++++++++++" << std::endl;
  std::cout << "==============" << std::endl;
  cv::ocl::Device d = cv::ocl::Device::getDefault();
  std::cout << d.OpenCLVersion();
  std::cout << "==============" << std::endl;
}

Output of everything (not buildinfo):

using optimized
no opencl
failed to create
0 GPU devices are detected.
++++++++++++++
++++++++++++++
==============
==============

Build info is 3 screenshot parts 1-3 C:\fakepath\part1.png C:\fakepath\part2.png C:\fakepath\part3.png

Let me know if you need more information Thanks in advance

click to hide/show revision 2
None

updated 2018-07-16 20:12:31 -0600

berak gravatar image

OpenCL context does not get created

Don't really know how to word it, but long story short, I have built OpenCV from source cv::getBuildInformation() says that OpenCL is indeed installed. I have an GTX 1050, CV is also compiled with CUDA. Ubuntu 16.04. I have the same code on my work computer (has i7-4610m and AMD 8960m) CV is built from source with OpenCL and it gives me the info

Code used:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>


int main(int argc, char **argv)
{
  cv::ocl::setUseOpenCL(true);
  cv::setUseOptimized(true);
  std::cout << cv::getBuildInformation() << std::endl;
  if (cv::useOptimized())
  {
     std::cout << "using optimized" << std::endl;
  }

  if (!cv::ocl::haveOpenCL())
  {
     std::cout << "no opencl" << std::endl;
  }

  cv::ocl::Context context;
  if (!context.create(cv::ocl::Device::TYPE_GPU)) //I've tried all of the TYPE_ they all do the same thing
  {
     std::cout << "failed to create" << std::endl;
  }
  std::cout << context.ndevices() << " GPU devices are detected." << std::endl;
  std::cout << "++++++++++++++" << std::endl;
  for (size_t i = 0; i < context.ndevices(); i++)
  {
     cv::ocl::Device device = context.device(i);
     std::cout << "name: " << device.name() << std::endl;
     std::cout << "available: " << device.available() << std::endl;
     std::cout << "img support: " << device.imageSupport() << std::endl;
     std::cout << "cl v: " << device.OpenCL_C_Version() << std::endl;
  }
  std::cout << "++++++++++++++" << std::endl;
  std::cout << "==============" << std::endl;
  cv::ocl::Device d = cv::ocl::Device::getDefault();
  std::cout << d.OpenCLVersion();
  std::cout << "==============" << std::endl;
}

Output of everything (not buildinfo):

using optimized
no opencl
failed to create
0 GPU devices are detected.
++++++++++++++
++++++++++++++
==============
==============

Build info is 3 screenshot parts 1-3 C:\fakepath\part1.png C:\fakepath\part2.png C:\fakepath\part3.png1-3

Let me know if you need more information Thanks in advance

OpenCL context does not get created

Don't really know how to word it, but long story short, I have built OpenCV from source cv::getBuildInformation() says that OpenCL is indeed installed. I have an GTX 1050, CV is also compiled with CUDA. Ubuntu 16.04. I have the same code on my work computer (has i7-4610m and AMD 8960m) CV is built from source with OpenCL and it gives me the info

Code used:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>


int main(int argc, char **argv)
{
  cv::ocl::setUseOpenCL(true);
  cv::setUseOptimized(true);
  std::cout << cv::getBuildInformation() << std::endl;
  if (cv::useOptimized())
  {
     std::cout << "using optimized" << std::endl;
  }

  if (!cv::ocl::haveOpenCL())
  {
     std::cout << "no opencl" << std::endl;
  }

  cv::ocl::Context context;
  if (!context.create(cv::ocl::Device::TYPE_GPU)) //I've tried all of the TYPE_ they all do the same thing
  {
     std::cout << "failed to create" << std::endl;
  }
  std::cout << context.ndevices() << " GPU devices are detected." << std::endl;
  std::cout << "++++++++++++++" << std::endl;
  for (size_t i = 0; i < context.ndevices(); i++)
  {
     cv::ocl::Device device = context.device(i);
     std::cout << "name: " << device.name() << std::endl;
     std::cout << "available: " << device.available() << std::endl;
     std::cout << "img support: " << device.imageSupport() << std::endl;
     std::cout << "cl v: " << device.OpenCL_C_Version() << std::endl;
  }
  std::cout << "++++++++++++++" << std::endl;
  std::cout << "==============" << std::endl;
  cv::ocl::Device d = cv::ocl::Device::getDefault();
  std::cout << d.OpenCLVersion();
  std::cout << "==============" << std::endl;
}

Output of everything (not buildinfo):

using optimized
no opencl
failed to create
0 GPU devices are detected.
++++++++++++++
++++++++++++++
==============
==============

Build info is 3 screenshot parts 1-3

Let me know if you need more information Thanks in advance

edit1: Build info

General configuration for OpenCV 3.4.2-dev =====================================
Version control:               unknown

Platform:
  Timestamp:                   2018-07-15T17:34:22Z
  Host:                        Linux 4.13.0-45-generic x86_64
  CMake:                       3.11.4
  CMake generator:             Unix Makefiles
  CMake build tool:            /usr/bin/make
  Configuration:               Release

CPU/HW features:
  Baseline:                    SSE SSE2 SSE3
    requested:                 SSE3
  Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
    requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
    SSE4_1 (3 files):          + SSSE3 SSE4_1
    SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
    FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
    AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
    AVX2 (8 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
    AVX512_SKX (0 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

C/C++:
  Built as dynamic libs?:      YES
  C++11:                       YES
  C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
  C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden   -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
  C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden   -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
  C Compiler:                  /usr/bin/cc
  C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG    -DNDEBUG
  C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0   -DDEBUG -D_DEBUG
  Linker flags (Release):      
  Linker flags (Debug):        
  ccache:                      NO
  Precompiled headers:         YES
  Extra dependencies:          dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
  3rdparty dependencies:

OpenCV modules:
  To be built:                 calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev features2d flann highgui imgcodecs imgproc ml objdetect photo python2 python_bindings_generator shape superres ts video videoio videostab
  Disabled:                    dnn java_bindings_generator js stitching world
  Disabled by dependency:      -
  Unavailable:                 java python3 viz
  Applications:                tests perf_tests apps
  Documentation:               NO
  Non-free algorithms:         NO

GUI: 
  GTK+:                        YES (ver 2.24.30)
    GThread :                  YES (ver 2.48.2)
    GtkGlExt:                  NO
  OpenGL support:              NO
  VTK support:                 NO

Media I/O: 
  ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
  JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
  WEBP:                        build (ver encoder: 0x020e)
  PNG:                         build (ver 1.6.34)
  TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.6)
  JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
  OpenEXR:                     build (ver 1.7.1)
  HDR:                         YES
  SUNRASTER:                   YES
  PXM:                         YES

Video I/O:
  DC1394:                      YES (ver 2.2.4)
  FFMPEG:                      YES
    avcodec:                   YES (ver 56.60.100)
    avformat:                  YES (ver 56.40.101)
    avutil:                    YES (ver 54.31.100)
    swscale:                   YES (ver 3.1.101)
    avresample:                NO
  GStreamer:                   NO
  libv4l/libv4l2:              NO
  v4l/v4l2:                    linux/videodev2.h
  gPhoto2:                     NO

Parallel framework:            TBB (ver 2018.0 interface 10001)

Trace:                         YES (with Intel ITT)

Other third-party libraries:
  Intel IPP:                   2017.0.3 [2017.0.3]
         at:                   /home/siddharth/OPENCV/Build/3rdparty/ippicv/ippicv_lnx
  Intel IPP IW:                sources (2017.0.3)
            at:                /home/siddharth/OPENCV/Build/3rdparty/ippicv/ippiw_lnx
  Lapack:                      NO
  Eigen:                       YES (ver 3.2.92)
  Custom HAL:                  NO
  Protobuf:                    build (3.5.1)

NVIDIA CUDA:                   YES (ver 8.0, CUFFT CUBLAS)
  NVIDIA GPU arch:             61

OpenCL:                        YES (no extra features)
  Include path:                /home/siddharth/OPENCV/opencv-3.4/3rdparty/include/opencl/1.2
  Link libraries:              Dynamic load

Python 2:
  Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
  Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
  numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
  packages path:               lib/python2.7/dist-packages

Python (for build):            /usr/bin/python2.7

Install to:                    /usr/local

OpenCL context does not get created

Don't really know how to word it, but long story short, I have built OpenCV from source cv::getBuildInformation() says that OpenCL is indeed installed. I have an GTX 1050, CV is also compiled with CUDA. Ubuntu 16.04. I have the same code on my work computer (has i7-4610m and AMD 8960m) CV is built from source with OpenCL and it gives me the info

Code used:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>


int main(int argc, char **argv)
{
  cv::ocl::setUseOpenCL(true);
  cv::setUseOptimized(true);
  std::cout << cv::getBuildInformation() << std::endl;
  if (cv::useOptimized())
  {
     std::cout << "using optimized" << std::endl;
  }

  if (!cv::ocl::haveOpenCL())
  {
     std::cout << "no opencl" << std::endl;
  }

  cv::ocl::Context context;
  if (!context.create(cv::ocl::Device::TYPE_GPU)) //I've tried all of the TYPE_ they all do the same thing
  {
     std::cout << "failed to create" << std::endl;
  }
  std::cout << context.ndevices() << " GPU devices are detected." << std::endl;
  std::cout << "++++++++++++++" << std::endl;
  for (size_t i = 0; i < context.ndevices(); i++)
  {
     cv::ocl::Device device = context.device(i);
     std::cout << "name: " << device.name() << std::endl;
     std::cout << "available: " << device.available() << std::endl;
     std::cout << "img support: " << device.imageSupport() << std::endl;
     std::cout << "cl v: " << device.OpenCL_C_Version() << std::endl;
  }
  std::cout << "++++++++++++++" << std::endl;
  std::cout << "==============" << std::endl;
  cv::ocl::Device d = cv::ocl::Device::getDefault();
  std::cout << d.OpenCLVersion();
  std::cout << "==============" << std::endl;
}

Output of everything (not buildinfo):

using optimized
no opencl
failed to create
0 GPU devices are detected.
++++++++++++++
++++++++++++++
==============
==============

Let me know if you need more information Thanks in advance

edit1: Build info

General configuration for OpenCV 3.4.2-dev =====================================
Version control:               unknown

Platform:
  Timestamp:                   2018-07-15T17:34:22Z
  Host:                        Linux 4.13.0-45-generic x86_64
  CMake:                       3.11.4
  CMake generator:             Unix Makefiles
  CMake build tool:            /usr/bin/make
  Configuration:               Release

CPU/HW features:
  Baseline:                    SSE SSE2 SSE3
    requested:                 SSE3
  Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
    requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
    SSE4_1 (3 files):          + SSSE3 SSE4_1
    SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
    FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
    AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
    AVX2 (8 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
    AVX512_SKX (0 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

C/C++:
  Built as dynamic libs?:      YES
  C++11:                       YES
  C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
  C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden   -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
  C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden   -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
  C Compiler:     /usr/bin/cc
  C flags (Release):  -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG    -DNDEBUG
  C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0   -DDEBUG -D_DEBUG
  Linker flags (Release):      
  Linker flags (Debug):        
  ccache:                      NO
  Precompiled headers:   YES
  Extra dependencies:   dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
  3rdparty dependencies:

OpenCV modules:
  To be built:  calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev features2d flann highgui imgcodecs imgproc ml objdetect photo python2 python_bindings_generator shape superres ts video videoio videostab
  Disabled:                    dnn java_bindings_generator js stitching world
  Disabled by dependency:      -
  Unavailable:                 java python3 viz
  Applications:                tests perf_tests apps
  Documentation:               NO
  Non-free algorithms:         NO

GUI: 
  GTK+:                        YES (ver 2.24.30)
    GThread :                  YES (ver 2.48.2)
    GtkGlExt:                  NO
  OpenGL support:              NO
  VTK support:                 NO

Media I/O: 
  ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
  JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
  WEBP:                        build (ver encoder: 0x020e)
  PNG:                         build (ver 1.6.34)
  TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.6)
  JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
  OpenEXR:                     build (ver 1.7.1)
  HDR:                         YES
  SUNRASTER:                   YES
  PXM:                         YES

Video I/O:
  DC1394:                      YES (ver 2.2.4)
  FFMPEG:                      YES
    avcodec:                   YES (ver 56.60.100)
    avformat:                  YES (ver 56.40.101)
    avutil:                    YES (ver 54.31.100)
    swscale:                   YES (ver 3.1.101)
    avresample:                NO
  GStreamer:                   NO
  libv4l/libv4l2:              NO
  v4l/v4l2:                    linux/videodev2.h
  gPhoto2:                     NO

Parallel framework:            TBB (ver 2018.0 interface 10001)

Trace:                         YES (with Intel ITT)

Other third-party libraries:
  Intel IPP:                   2017.0.3 [2017.0.3]
         at:                   /home/siddharth/OPENCV/Build/3rdparty/ippicv/ippicv_lnx
  Intel IPP IW:                sources (2017.0.3)
            at:                /home/siddharth/OPENCV/Build/3rdparty/ippicv/ippiw_lnx
  Lapack:                      NO
  Eigen:                       YES (ver 3.2.92)
  Custom HAL:                  NO
  Protobuf:                    build (3.5.1)

NVIDIA CUDA:                   YES (ver 8.0, CUFFT CUBLAS)
  NVIDIA GPU arch:             61

OpenCL:                        YES (no extra features)
  Include path:                /home/siddharth/OPENCV/opencv-3.4/3rdparty/include/opencl/1.2
  Link libraries:              Dynamic load

Python 2:
  Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
  Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
  numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
  packages path:               lib/python2.7/dist-packages

Python (for build):            /usr/bin/python2.7

Install to:                    /usr/local