PyOpenCL无法在MacOS Mojave上构建程序

问题描述 投票:0回答:1

所以我试图使用silx.image.sift运行一个程序,它使用pyopencl。在运行该软件时,我遇到了构建openCL程序的问题,并且我已将程序隔离到以下代码中,该代码重现了错误:

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)

由于这段代码是基本的,我猜它是(遗憾地)最近安装的macOS Mojave的一个错误。这是我运行使用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>:

不确定这是一个pyopencl问题还是一般的opencl问题。我知道OpenCL在macOS mojave中被弃用了,但是这不应该意味着它不能正常工作吗?

python python-3.x opencl pyopencl macos-mojave
1个回答
1
投票

根据PyOpenCL的开发人员的说法,这是Mac OS 10.14上的一个已知问题。早期版本显然不受影响。

解决方案是在运行python或jupyter notebook之前在终端中使用该命令:

export PYOPENCL_NO_CACHE=1
热门问题
推荐问题
最新问题