OpenCL in OpenCV 3 does not see more than one GPU - c++

I was trying to call the Nvidia GT 650M GPU on my MacBook Pro, whose index is 1, with the integrated GPU having index 0. (as found from running $ clinfo)
Just as mentioned in this StackOverflow question:
In OpenCV 3.0.0 beta [or above], only a single device is detected:
context.ndevices() // returns 1 instead of 2
When I run the code in the answer above, OpenCV will always use the first GPU, despite setting cv::ocl::Device(context.device(1));
A discussion thread in the OpenCV forum says that this might be due to the compatibility (1.1) of the Nvidia GPU on the platform, but that is not the case for me.
I wrote a simple OpenCL program to create a context on the Nvidia GPU and run the kernel, and it succeeded. So it is not a OpenCL hardware compatibility issue (the Apple support article also confirms this).
What I tried and not seems to be helping:
Turn off auto graphics switching in System Preferences.
Switch to Nvidia Web Driver (from macOS native driver) and install CUDA.
OpenCL: 1.2, on both GPUs
OpenCV: 3.4.1, from HomeBrew
OS: macOS High Sierra 10.13.4
Xcode: 9.3

Related

Is it possible to upgrade OpenGL to version 4.3 on Google Compute Engine with GPU Grid drivers?

I tried to set up a Google Compute Engine with Ubuntu 20.4 using GPU Grid drivers ( NVIDIA Tesla P100 Virtual Workstation). Since I need CUDA 10.2 for my project which requires TensorFlow 1.15 I installed this GPU Grid driver as recommended on Google Cloud document site and here is the result.
NVIDIA-SMI 440.87 Driver Version: 440.87 CUDA Version: 10.2
I supposed that NVIDIA Tesla P100 supports Opengl 4.5 as it is mentioned on Tesla release notes. However, after connecting to this VM with a visual remote connection (I used NoMachine), I ran this command [glxinfo | grep "OpenGL"] to double-check, it showed OpenGL version 1.4 only
OpenGL vendor string: Mesa Project
OpenGL renderer string: Software Rasterizer
OpenGL version string: 1.4 (2.1 Mesa 13.0.2)
OpenGL extensions:
The problem is that the application I am trying to run on this VM (Carla simulator) requires Opengl 4.3++, I just wonder if there is any way to upgrade Opengl to version 4.3?
According to the last comment, preloading a library for the NVIDIA driver, where the NVIDIA GPU may also be detected as a secondary video card is a good option you can take since you can get your software to use the actual hardware. Were you able to try this suggestion?
I've filed a Feature Request on your behalf for the product team to check if it is possible to evaluate the possibility to implement the functionality that fits your use case, you can follow up on this PIT [1], where you will be able to receive further updates from the team as well
Keep in mind that there is no ETA, nor guarantee that this will be implmented. However, please feel free to ask for updates directly on the PIT.
[1] https://issuetracker.google.com/168843661

OpenCL development on Intel CPU/GPU under Linux

I have an intel i7 haswell cpu, and I would like to start exploring OpenCL development. In particular, I am interested to run OpenCL code on the integrated GPU.
Unfortunately, by now, I was not able to find any SDK on Intel's site..
May you provide some links, together with a summary of the current status of OpenCL tools for the Linux platform and Intel hardware?
I think this would be useful to many other people..
Thanks a lot!
Intel does not provide free support for OpenCL on their iGPUs under Linux - you have to buy the Intel Media Server Studio, minimum $499. On Windows, you can download a free driver to get OpenCL capability for the iGPU: https://software.intel.com/en-us/articles/opencl-drivers#philinux.
Note that you can use any OpenCL SDK you want - it doesn't have to be Intel. The SDK is only useful for building your program. For running an OpenCL program, you need an appropriate runtime (driver) from the manufacturer. The AMD SDK will give you access to the CPU as an OpenCL device, but not the iGPU.
There is Open Source OpenCL implementation for Intel GPUs on Linux called Beignet, maintained by bunch of guys from Intel.
Sadly, couldn't personally try and check if Your's GPU is properly supported, but on their wiki they states:
Supported Targets
4th Generation Intel Core Processors "Haswell", need kernel patch currently, see the "Known Issues" section.
Beignet: self-test failed" and almost all unit tests fail. Linux 3.15 and 3.16 (commits f0a346b to c9224fa) enable the register whitelist by default but miss some registers needed for Beignet.
This can be fixed by upgrading Linux, or by disabling the whitelist:
# echo 0 > /sys/module/i915/parameters/enable_cmd_parser
On Haswell hardware, Beignet 1.0.1 to 1.0.3 also required the above workaround on later Linux versions, but this should not be required in current (after 83f8739) git master.
So, it's worth a shoot. Btw, it worked well on my 3rd generation HD4000.
Also, toolchain and driver in question includes bunch of GPU-support test cases.
For anyone who comes across this question as I did, the existing answers have some out-of-date information; Intel now offers free drivers for Linux on the site posted above: https://software.intel.com/en-us/articles/opencl-drivers#philinux
The drivers themselves are only supported on 5th, 6th and 7th gen Core processors (and a bunch of other Celerons and Xeons, see link), with earlier processors such as 4th gen still needing the Media Server Studio.
However, they now offer a Linux Community version of Media Server Studio which is free to download.
They also have a Driver Support Matrix for Intel Media SDK and OpenCL which has some useful information about compatibility: https://software.intel.com/en-us/articles/driver-support-matrix-for-media-sdk-and-opencl
You may check intel open source Beignet OpenCL library: http://arrayfire.com/opencl-on-intel-hd-iris-graphics-on-linux/
For me (ubuntu 15.10 + Intel i5 4th generation GPU) it works quite well.
P.S.
Also I must say that I managed to download "media server" for linux a couple of months ago (but didn't used it yet). So you may check it also.

How can I check which Version of OpenGL is supported on a linux system with optirun?

I have had a lot of problems / confusion setting up my laptop to work for OpenGL programming / the running of OpenGL programs.
My laptop has one of these very clever (too clever for me) designs where the Intel CPU has a graphics processor on chip, and there is also a dedicated graphics card. Specifically, the CPU is a 3630QM, with "HD Graphics 4000" (a very exciting name, I am sure), and the "proper" Graphics Processor is a Nvidia GTX 670MX.
Theoretically, according to Wikipedia, the HD Graphics Chip (Intel), under Linux, supports OpenGL 3.1, if the correct drivers are installed. (They probably aren't.)
According to NVIDIA, the 670MX can support OpenGL 4.1, so ideally I would like to develop and execute on this GPU.
Do I have drivers installed to enable me to execute OpenGL 4.1 code on the NVIDIA GPU? Answer: Probably no, currently I use this "optirun" thing to execute OpenGL programs on the dedicated GPU. See this link to see the process I followed to setup my computer.
My question is, I know how to run a compiled program on the 670MX; that would be 'optirun ./programname', but how can I find out what OpenGL version the installed graphics drivers on my system will support? Running 'glxinfo | grep -i opengl' in a terminal tells me that the Intel Chip supports OpenGl version 3.0. See the below information:
ed#kubuntu1304-P151EMx:~$ glxinfo | grep -i opengl
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL version string: 3.0 Mesa 9.1.3
OpenGL shading language version string: 1.30
OpenGL extensions:
How do I do the same or similar thing to find out what support is available under 'optirun', and what version of OpenGL is supported?
Update
Someone suggested I use glGetString() to find this information: I am now completely confused!
Without optirun, the supported OpenGL version is '3.0 MESA 9.1.3', so version 3, which is what I expected. However, under optirun, the supported OpenGL version is '4.3.0 NVIDIA 313.30', so version 4.3?! How can it be Version 4.3 if the hardware specification from NVIDIA states only Version 4.1 is supported?
You can just run glxinfo under optirun:
optirun glxinfo | grep -i opengl
Both cards have different features, so its normal to get different OpenGL versions.

How can I use OpenCL in my system

I have a laptop running Ubuntu, it has a 32 Bits processor (Intel Core 2 Duo T6400 2.00GHz) and a graphics card Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller. I would like to know if I can program with OpenCL in this system. If yes what do I need?
I have been searching Google, ofcourse. I found this page:
http://software.intel.com/en-us/articles/download-intel-opencl-sdk/
But I only found a RPM package in the Linux section. I can install it in my Ubuntu system, but the package is for a 64 bit system.
Unfortunately you will need the following distributions:
http://software.intel.com/en-us/articles/opencl-release-notes/
Novell* SUSE* Linux Enterprise Server 11 Service Pack 1 (64-bit version)
Red Hat* Enterprise Linux 6 (64-bit version).
If you cannot change distribution, an alternate way is to use NVIDIA's CUDA SDK in emulation mode. It will be slow, but will work.
Try AMD's APP SDK (link). It has 32 bit version and runs on Intel CPUs without any problems.
Using Intel GPUs for OpenCL is impossible right now.
Intel does not support GPU accelerated OpenCL as of now. The OpenCL SDK you linked in your question will run on your CPU. So yes, no matter what GPU you have in your system, you will be able to do OpenCL -- albeit on the CPU.
Furthermore Intel only provides an RPM. You can try to use Alien to install it on your Ubuntu system, if you had a 64bit CPU. The only thing you could do now would be to get an NVIDIA or AMD GPU and use their OpenCL SDKs respectively. Or get a new computer with Intel CPU / and 64 bit support.

OpenCL doesn't find ATI card

I have a notebook with ATI Mobility Radeon HD 5650, and want to use the card for computing =) After installing AMD APP SDK v.2 (installation was OK) I tried to run code samples, provided with AMD. But there is a problem: when I run a sample, it doesn't find my ATI card - in the list of available OpenCL devices there is only CPU (Intel Core i5), but not GPU.
How to solve this problem and run some code on GPU?
Your video card drivers must support OpenCL. I suggest you try downloading the newest drivers from your vendor. Unfortunately most mobile graphic cards are supported by the distributor of the PC and not of the graphics card vendor, so I am not sure if you can find any according drivers.
Not all ATI's GPU support OpenCL, looking into the list of supported devices you can see that this card is not there, neither with beta support. So basically you can only buy different card (what can be rather problematic with a laptop).
I have the same problem in my Acer 3820TG. However, the OpenCL programming is needed the driver version over 8.753.1. It seems that Acer doesn't support in currently.
One way to overcome this problem is to force install the newer mobility drivers from AMD.
You can follow the the steps from:
http://www.sevenforums.com/drivers/177042-force-install-drivers.html
and then try the related-stable driver to install.
(It means it also supports the HD5650-M , but it is different SUBSYS num.)
In my testing, don't install the newest driver(Or you would have the OSDC problem). I install the driver version at about 8.79-8.80(10-11_vista64_win7_64_dd_ccc or
10-12_vista64_win7_64_dd_ccc) and then it seems that it can work.