Error: Clgetplatformids -1001 When Running Opencl Code (Linux)

ERROR: clGetPlatformIDs -1001 when running OpenCL code (Linux)

(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

sudo ln -s /usr/share/nvidia-331/nvidia.icd /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 or primusrun:

optirun myopenclprogram

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

sudo tee /proc/acpi/bbswitch <<< ON
sudo modprobe nvidia

Turn graphics card off (nvidia module is automatically unloaded)

sudo tee /proc/acpi/bbswitch <<< OFF

clGetPlatformIDs failed: unknown error -1001

The easiest way to use OpenCL on EC2 is by using the Deep Learning Base Image, which comes with all necessary drivers and is already configured to work with P2 and P3 instance types. The image can be found at https://aws.amazon.com/marketplace/pp/B077GCH38C.

-1001 error in OpenCL with Nvidia card in Ubuntu Linux

The above mentioned problems occurred due to a driver conflict. If you have a similar problem then read the above edits to get the solution.

clGetPlatformIDs error -1001 when called in PostgreSQL UDF

It's MSFT's problem with Windows, Services, GPUs, Security and device drivers.

You can't run PostgreSQL as a service on Windows AND see any GPUs. You are hitting Session O Isolation which does NOT allow any 'graphics' device access from a Windows Service. You can start PostgreSQL as a process (not a service) or put the server on Linux.

See http://www.scribd.com/doc/58343489/Windows-Session-0-Isolation-Impact-on-GPU-as-Service

Also there are other important reasons to run on Linux, as Windows will want to reboot your GPU if the screen is not accessed before the timeout period. See
http://msdn.microsoft.com/en-us/library/windows/hardware/ff570088%28v=vs.85%29.aspx

NVida have a non-graphics GPU device driver for specific Tesla cards on Windows. These cards don't have any video output. So they aren't considered to be graphics device drivers.

OpenCL not finding platforms?

My sincerest thanks to @pasternak for helping me troubleshoot this problem. To solve it however I ended up needing to avoid essentially all ubuntu apt-get calls for install and just use the cuda run file for the full installation. Here is what fixed the problem.

  1. Purge existing nvidia and cuda implementations (sudo apt-get purge cuda* nvidia-*)
  2. Download cuda-6.5 toolkit from the CUDA toolkit archive
  3. Reboot computer
  4. Switch to ttyl (Ctrl-Alt-F1)
  5. Stop the X server (sudo stop lightdm)
  6. Run the cuda run file (sh cuda_6.5.14_linux_64.run)
  7. Select 'yes' and accept all defaults
  8. Required reboot
  9. Switch to ttyl, stop X server and run the cuda run file again and select 'yes' and default for everything (including the driver again)
  10. Update PATH to include /usr/local/cuda-6.5/bin and LD_LIBRARY_PATH
    to include /usr/local/cuda-6.5/lib64
  11. Reboot again
  12. Compile main.c program (gcc main.c -o vectorAddition -l OpenCL -I/usr/local/cuda-6.5/include)
  13. Verify works with ./vectorAddition

C++ API

  1. Download cl.hpp file from Khronos here noting that it is version 1.1
  2. Place cl.hpp file in /usr/local/cuda-6.5/include/CL with other cl headers.
  3. Compile main.cpp (g++ main.cpp -o vectorAddition_cpp -std=c++11 -l OpenCL -I/usr/local/cuda-6.5/include)
  4. Verify it works (./vectorAddition_cpp)

All output from both programs show the correct output for addition between vectors.

I personally find it interesting the Ubuntu's nvidia drivers don't seem to play well with the cuda toolkits. Possibly just for the older versions but still very unexpected.



Related Topics



Leave a reply



Submit