After finally managing to get my code to compile with OpenCL, I cannot seem to get the output binary to run! This is on my linux laptop running Kubuntu 13.10 x64
The error I get is (Printed from cl::Error):
ERROR: clGetPlatformIDs
-1001
I found this post but there does not seem to be a clear solution.
I added myself to the video group but this does not seem to work.
With regards to the ICD profile... I am not sure what I need to do - shouldn't this be included with the cuda toolkit? If not, where could I download one?
EDIT: It seems I have an ICD file in my system under /usr/share/nvidia-331/nvidia.icd. It contains the following text:
libnvidia-opencl.so.1
The only file in my system that resembles this is:
/usr/lib/nvidia-331/libnvidia-opencl.so.331.20
Is my ICD profile somehow wrong? Does anyone know a way to fix it?
To share some add info. I have installed intel opencl version on Ubuntu 13.10 saucy. Problem has been the same: -1001 error. I solved it by link analogicly to previous post:
(Mods: I am not sure if this post should be moved to AskUbuntu seeing as it was an issue related to Linux bumblebee rather than OpenCL itself?)
Ok so I managed to solve the issue after loads of effort.
There are two things that I needed to do:
Getting ICD to work
create a symbolic link from /usr/share/nvidia-331/nvidia.icd to /etc/OpenCL/vendors
NOTE: In most cases you would need to replace nvidia-331 with whatever driver you are using - most commonly nvidia-current
I am really curious as to why this isn't done automatically when installing the cuda toolkit - but I have noticed that OpenCL programs will not work without this step!
Nvidia Optimus with Bumblebee
The reason why this was so complicated to get working was that I have an nvidia optimus laptop with poor driver support on linux. To fix this I have bumblebee installed to allow switching between my nvidia card and intel card.
However, because I am using bumblebee - the nvidia graphics card (and nvidia driver) will be unloaded unless explicitly told so. In order to use OpenCL, we need to turn on the nvidia graphics card.
To do this we need to explicitly tell bumblebee to turn the nvidia card on by using the commands
optirun
orprimusrun
:Note however, because all that matters is that the nvidia card is turned on and the drivers are loaded, you do not need to keep using
optirun myprogram
to get this to work (as this always involves the initial delay of waiting for the graphics card to be initialised).You can run
optirun kate
for example and this would turn on the nvidia graphics card. You can then, in a separate terminal just run you opencl program without optirun and it will work just fine since the graphics card has already been turned on (and will remain on as long as you leave e.g. kate running).You will notice that there is no delay in starting your program this time! This saves you alot of waiting - especially if you are developing the opencl program in question.
Once again, as long as you keep the nvidia graphics card turned on, your opencl program will work.
I will probably contact the bumblebee devs to see if there is an easier way to get this to work and report what they say here. Hopefully there is some way to turn the nvidia card on and off without requiring to keep a program (like kate in my example) running.
I hope this helps anyone trying to use OpenCL on linux laptops with bumblebee in the future (I could not find any clear cut solutions myself)
EDIT2: Turning you graphics card on and off can be done as follows for bumlebee users:
Turn graphics card on and load nvidia module
Turn graphics card off (nvidia module is automatically unloaded)