Joe
Joe

Reputation: 1958

PyOpenCL fails to build program on MacOS Mojave

So I'm trying to run a program using silx.image.sift, which uses pyopencl. While running the software, I ran into a problem building the openCL program and I've isolated the program to the following code which reproduces the error:

import numpy as np
import pyopencl as cl
from pyopencl.clrandom import rand as clrand


context = cl.create_some_context()
queue = cl.CommandQueue(context)
clrand(queue, (50,), np.float32)

Since this code is as basic as it gets, I'm guessing it's a bug with the (regretfully) recently installed macOS Mojave. Here is the error I consistently get whenever I run code that uses pyopencl:

 File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyopencl/clrandom.py",
  line 642, in _fill
    self.get_gen_kernel(ary.dtype, distribution)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytools/__init__.py",
   line 598, in wrapper
    result = function(obj, *args, **kwargs)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyopencl/clrandom.py",
  line 623, in get_gen_kernel
    prg = cl.Program(self.context, src).build()
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyopencl/__init__.py",
   line 510, in build
    options_bytes=options_bytes, source=self._source)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyopencl/__init__.py",
   line 554, in _build_and_catch_errors
    raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE -
   clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on <pyopencl.Device 'Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz' on 'Apple' at 0xffffffff>:

Not sure whether this is a pyopencl issue or a general opencl problem. I understand that OpenCL is deprecated in macOS mojave, but that shouldn't mean that it won't work at all right?

Upvotes: 0

Views: 1533

Answers (1)

According to the developer of PyOpenCL, it's a known problem on Mac OS 10.14. Earlier versions are apparently not affected.

The solution is to use the command in terminal, before running python or jupyter notebook:

export PYOPENCL_NO_CACHE=1

Upvotes: 2

Related Questions