首页 > 解决方案 > 我不能通过 ctypes 通过 Python 使用 OpenCL

问题描述

我正在尝试通过 pythons ctypes 库通过 python 使用 opencl。在我正在使用的新机器上,没有任何工作了。我收到以下错误:

回溯(最后一次调用):文件“D:\why_like_this.py”,第 10 行,在 succ = clGetPlatformIDs(1,pIDs,0) OSError:异常:访问冲突写入 0x0000000000000000

以下是导致问题的简单 python 代码:

import ctypes

opencl = ctypes.WinDLL('OpenCL')

clGetPlatformIDs = opencl.clGetPlatformIDs
clGetPlatformIDs.restype = ctypes.c_int32
clGetPlatformIDs.argtypes = [ctypes.c_uint32, ctypes.c_void_p, ctypes.c_void_p]

pIDs = (ctypes.c_int64*1)()
succ = clGetPlatformIDs(1,pIDs,0)

标签: pythonopenclctypes

解决方案


问题是糟糕的运行时库。重新安装系统的视频驱动程序后,错误消失了。


推荐阅读