Ubuntu – Why OpenCL is not default (14.04, nVidia 331)

14.04boincdarktabledriversnvidiaopencl

I am only one without OpenCL or it is a common problem?

UPDATE: It appears that something removed /etc/OpenCL/vendors/nvidia.icd, which should have been installed with nvidia-opencl-icd-331, but it doesn't.

It started with BOINC. It refused to calculate Milkyway data specifically fetched for my GPU:

Starting BOINC client version 7.2.42 for i686-pc-linux-gnu
...
CUDA: NVIDIA GPU 0: GeForce GT 520 (driver version unknown, CUDA version 6.0,
 compute capability 2.1, 1023MB, 999MB available, 156 GFLOPS peak)
...
Requesting new tasks for CPU and NVIDIA
App version needs OpenCL but GPU doesn't support it
Scheduler request completed: got 2 new tasks
[error] App version uses non-existent NVIDIA GPU
[error] Missing coprocessor for task de_modfit_fast_simulated15_136_free_1_14
13455402_27741174_0; aborting

So I decided to check why there is no OpenCL. I couldn't find "official" way to check for OpenCL support, but I found people use :

$ darktable -d opencl
[opencl_init] opencl related configuration options:
...
[opencl_init] trying to load opencl library: '<system default>'
[opencl_init] opencl library 'libOpenCL' found on your system and loaded
[opencl_init] could not get platforms: -1001
[opencl_init] FINALLY: opencl is NOT AVAILABLE on this system.

Also tried to detect anything with pyrit:

$ pyrit list_cores
Pyrit 0.4.0 (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

The following cores seem available...
#1:  'CPU-Core (SSE2)'
#2:  'CPU-Core (SSE2)'

Finally discovered clinfo:

$ clinfo
I: ICD loader reports no usable platforms

And then How to make OpenCL work on 14.10 + Nvidia 331.89 drivers?

I still couldn't get why BOINC can't detect version of nVidia driver, so I removed boinc and installed boinc-nvidia-cuda, but the problem did not go away. I also tried to see if there is anything with opencl missing, but it seems fine.

The linked question says to install nvidia-modprobe. I am trying it right now. However, I don't get how this magic pill should work, and if it works – why it is not enabled by default? I also wonder if there should be some virtual package that does everything necessary to enable OpenCL?

Best Answer

I don't exactly know why its happening or how somehow the problem is solved.

First of all, the nvidia-331-uvm is not activated from the start (god knows why). So let's activate it:

$ sudo modprobe nvidia-331-uvm
$ sudo mknod -m 666 /dev/nvidia-uvm c 249 0

Then if you do clinfo you'll have the same error about the ICD loader. Nonetheless, if you do it as root:

$ sudo clinfo

You'll get a good result (E: -30), and then you're also able to run the command as a non-root user. Long story short:

$ clinfo
I: ICD loader reports no usable platforms
$ sudo clinfo 
E: -30
$ clinfo 
E: -30
# then you run anything as non-root user

Then, also darktable -d opencl works well, or any opencl program ;).

UPDATE

I finally added the next lines in my /etc/rc.local file:

# begin opencl config
modprobe nvidia-331-uvm
mknod -m 666 /dev/nvidia-uvm c 249 0
clinfo
# end opencl config 

Then everything works smoothly ;)

Related Question